Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thalia
concrexit
Commits
6aa5382c
Commit
6aa5382c
authored
Oct 21, 2016
by
Sébastiaan Versteeg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix frontend events form
parent
46257732
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
website/events/forms.py
website/events/forms.py
+5
-4
website/events/models.py
website/events/models.py
+2
-1
website/events/views.py
website/events/views.py
+7
-1
No files found.
website/events/forms.py
View file @
6aa5382c
from
django
import
forms
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
get_language
,
ugettext_lazy
as
_
from
.models
import
RegistrationInformationField
from
.models
import
RegistrationInformationField
class
RegistrationInformationFieldForm
(
forms
.
ModelForm
):
class
RegistrationInformationFieldForm
(
forms
.
ModelForm
):
order
=
forms
.
IntegerField
(
label
=
_
(
'order'
),
initial
=
0
)
order
=
forms
.
IntegerField
(
label
=
_
(
'order'
),
initial
=
0
)
class
Meta
:
class
Meta
:
...
@@ -36,8 +35,10 @@ class FieldsForm(forms.Form):
...
@@ -36,8 +35,10 @@ class FieldsForm(forms.Form):
elif
field
.
type
==
RegistrationInformationField
.
TEXT_FIELD
:
elif
field
.
type
==
RegistrationInformationField
.
TEXT_FIELD
:
self
.
fields
[
key
]
=
forms
.
CharField
()
self
.
fields
[
key
]
=
forms
.
CharField
()
self
.
fields
[
key
].
label
=
field
.
name
self
.
fields
[
key
].
label
=
getattr
(
field
,
'{}_{}'
.
format
(
self
.
fields
[
key
].
help_text
=
field
.
description
'name'
,
get_language
()))
self
.
fields
[
key
].
help_text
=
getattr
(
field
,
'{}_{}'
.
format
(
'description'
,
get_language
()))
self
.
fields
[
key
].
initial
=
information_field
[
'value'
]
self
.
fields
[
key
].
initial
=
information_field
[
'value'
]
if
not
field
.
type
==
RegistrationInformationField
.
BOOLEAN_FIELD
:
if
not
field
.
type
==
RegistrationInformationField
.
BOOLEAN_FIELD
:
self
.
fields
[
key
].
required
=
field
.
required
self
.
fields
[
key
].
required
=
field
.
required
...
...
website/events/models.py
View file @
6aa5382c
...
@@ -118,7 +118,8 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
...
@@ -118,7 +118,8 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
return
self
.
registrationinformationfield_set
.
count
()
>
0
return
self
.
registrationinformationfield_set
.
count
()
>
0
def
reached_participants_limit
(
self
):
def
reached_participants_limit
(
self
):
return
self
.
max_participants
<=
self
.
registration_set
.
count
()
return
(
self
.
max_participants
is
not
None
and
self
.
max_participants
<=
self
.
registration_set
.
count
())
@
property
@
property
def
status
(
self
):
def
status
(
self
):
...
...
website/events/views.py
View file @
6aa5382c
...
@@ -12,7 +12,7 @@ from django.utils import timezone
...
@@ -12,7 +12,7 @@ from django.utils import timezone
from
django.utils.text
import
slugify
from
django.utils.text
import
slugify
from
django.utils.translation
import
ugettext_lazy
as
_
,
pgettext_lazy
from
django.utils.translation
import
ugettext_lazy
as
_
,
pgettext_lazy
from
.models
import
Event
,
Registration
from
.models
import
Event
,
Registration
,
RegistrationInformationField
from
.forms
import
FieldsForm
from
.forms
import
FieldsForm
...
@@ -240,6 +240,12 @@ def registration(request, event_id, action=None):
...
@@ -240,6 +240,12 @@ def registration(request, event_id, action=None):
obj
.
save
()
obj
.
save
()
form_field_values
=
form
.
field_values
()
form_field_values
=
form
.
field_values
()
for
field
in
form_field_values
:
for
field
in
form_field_values
:
import
pdb
pdb
.
set_trace
()
if
(
field
[
'field'
].
type
==
RegistrationInformationField
.
INTEGER_FIELD
and
field
[
'value'
]
is
None
):
field
[
'value'
]
=
0
field
[
'field'
].
set_value_for
(
obj
,
field
[
'field'
].
set_value_for
(
obj
,
field
[
'value'
])
field
[
'value'
])
else
:
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment