Commit 6aa5382c authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Fix frontend events form

parent 46257732
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
class RegistrationInformationFieldForm(forms.ModelForm):
order = forms.IntegerField(label=_('order'), initial=0)
class Meta:
......@@ -36,8 +35,10 @@ class FieldsForm(forms.Form):
elif field.type == RegistrationInformationField.TEXT_FIELD:
self.fields[key] = forms.CharField()
self.fields[key].label = field.name
self.fields[key].help_text = field.description
self.fields[key].label = getattr(field, '{}_{}'.format(
'name', get_language()))
self.fields[key].help_text = getattr(field, '{}_{}'.format(
'description', get_language()))
self.fields[key].initial = information_field['value']
if not field.type == RegistrationInformationField.BOOLEAN_FIELD:
self.fields[key].required = field.required
......
......@@ -118,7 +118,8 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
return self.registrationinformationfield_set.count() > 0
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
def status(self):
......
......@@ -12,7 +12,7 @@ from django.utils import timezone
from django.utils.text import slugify
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
......@@ -240,6 +240,12 @@ def registration(request, event_id, action=None):
obj.save()
form_field_values = 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['value'])
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment