Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TIC-Desk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Teckids
TIC-Desk
Commits
bf9b6dd5
Verified
Commit
bf9b6dd5
authored
6 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add code to save addition registration fields, advances
#15
,
#26
,
#27
.
Introduces a change in instantiating the EventRegisterForm (now also needs teh current user passed).
parent
895fd748
No related branches found
No related tags found
1 merge request
!20
Add dynamic fields to event registration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ticdesk_events/forms.py
+26
-4
26 additions, 4 deletions
ticdesk_events/forms.py
ticdesk_events/views.py
+2
-2
2 additions, 2 deletions
ticdesk_events/views.py
with
28 additions
and
6 deletions
ticdesk_events/forms.py
+
26
−
4
View file @
bf9b6dd5
...
...
@@ -6,7 +6,7 @@ from localflavor.generic.forms import IBANFormField
from
localflavor.generic.countries.sepa
import
IBAN_SEPA_COUNTRIES
import
phonenumbers
from
.models
import
Voucher
from
.models
import
RegistrationField
,
Voucher
CHANNEL_CHOICES
=
[
(
'
none
'
,
_
(
'
Keine Angabe
'
)),
...
...
@@ -129,16 +129,24 @@ class EventRegisterForm(forms.Form):
clean_mobile
=
clean_phonenumber
(
'
mobile
'
)
clean_guardian_mobile
=
clean_phonenumber
(
'
guardian_mobile
'
)
def
__init__
(
self
,
project
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
project
,
person
,
*
args
,
**
kwargs
):
super
(
EventRegisterForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
_project
=
project
self
.
_person
=
person
self
.
fields
[
'
voucher_code
'
].
validators
.
append
(
is_valid_voucher_for
(
project
.
cn
))
EventAdditionSurveyForm
.
__init__
(
self
,
project
,
*
args
,
**
kwargs
)
EventAdditionSurveyForm
.
__init__
(
self
,
project
,
person
,
*
args
,
**
kwargs
)
def
save
(
self
):
super
(
EventRegisterForm
,
self
).
save
()
EventAdditionSurveyForm
.
save
(
self
)
class
EventAdditionalSurveyForm
(
forms
.
Form
):
def
__init__
(
self
,
project
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
project
,
person
,
*
args
,
**
kwargs
):
super
(
EventAdditionalSurveyForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
_project
=
project
self
.
_person
=
person
for
field
in
project
.
registration_fields
:
label
,
help_text
,
*
choices
=
field
.
split
(
'
|
'
)
...
...
@@ -152,6 +160,19 @@ class EventAdditionalSurveyForm(forms.Form):
self
.
fields
[
var
]
=
field_attr
def
save
(
self
):
for
field
in
self
.
_project
.
registration_fields
:
label
,
help_text
,
*
choices
=
field
.
split
(
'
|
'
)
var
=
re
.
sub
(
r
'
\W|^(?=\d)
'
,
'
_
'
,
label
)
try
:
field
=
RegistrationField
.
objects
.
get
(
project_cn
=
self
.
_project
.
cn
,
person_uid
=
self
.
_person
.
uid
,
title
=
label
)
except
RegistrationField
.
DoesNotExist
:
field
=
RegistrationFeild
.
objects
.
create
(
project_cn
=
self
.
_project
.
cn
,
person_uid
=
self
.
_person
.
uid
,
title
=
label
)
field
.
content
=
self
.
cleaned_data
[
var
]
field
.
save
()
class
EventFeedbackForm
(
forms
.
Form
):
comment_private
=
forms
.
CharField
(
required
=
False
,
label
=
_
(
'
Kommentar für das Team
'
),
help_text
=
_
(
'
Dieser Kommentar ist nur für das Team. Du kannst hier alles aufschreiben, was du uns noch als Feedback mitteilen möchtest.
'
),
...
...
@@ -177,6 +198,7 @@ class EventFeedbackForm(forms.Form):
def
__init__
(
self
,
project
,
*
args
,
**
kwargs
):
super
(
EventFeedbackForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
_project
=
project
for
aspect
in
project
.
feedback_aspects
:
var
=
re
.
sub
(
r
'
\W|^(?=\d)
'
,
'
_
'
,
aspect
)
...
...
This diff is collapsed.
Click to expand it.
ticdesk_events/views.py
+
2
−
2
View file @
bf9b6dd5
...
...
@@ -57,7 +57,7 @@ def register_event(request, cn):
'
school_class
'
:
current_person
.
ou
,
'
channel
'
:
'
none
'
}
register_form
=
EventRegisterForm
(
event
,
initial
=
initial
)
register_form
=
EventRegisterForm
(
event
,
current_person
,
initial
=
initial
)
# Produce error if registration is not possible
if
not
event
.
can_register
(
request
):
...
...
@@ -70,7 +70,7 @@ def register_event(request, cn):
return
render
(
request
,
'
ticdesk_events/register_event.html
'
,
context
)
if
request
.
method
==
'
POST
'
:
register_form
=
EventRegisterForm
(
event
,
request
.
POST
,
initial
=
initial
)
register_form
=
EventRegisterForm
(
event
,
current_person
,
request
.
POST
,
initial
=
initial
)
if
register_form
.
is_valid
():
# Add the current person to the event
event
.
add_member
(
current_person
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment