UPD: added app to submit participant registrations.
This commit is contained in:
43
dav_registration/forms.py
Normal file
43
dav_registration/forms.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
|
||||
from .models import Registration
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RegistrationForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Registration
|
||||
exclude = ['event', 'created_at', 'privacy_policy', 'purge_at']
|
||||
widgets = {
|
||||
'emergency_contact': forms.Textarea(attrs={'rows': 4}),
|
||||
'experience': forms.Textarea(attrs={'rows': 5}),
|
||||
'note': forms.Textarea(attrs={'rows': 5}),
|
||||
}
|
||||
|
||||
def clean_experience(self):
|
||||
val = self.cleaned_data.get('experience')
|
||||
if val == '':
|
||||
need_experience = True
|
||||
if self.instance.event.sport == 'W':
|
||||
need_experience = False
|
||||
if need_experience:
|
||||
raise forms.ValidationError(
|
||||
ugettext(u'Die Tourenleiter*innen brauchen ein paar Angaben,'
|
||||
u' was du bereits kannst oder wie fit du bist.'),
|
||||
code='need_experience',
|
||||
)
|
||||
return val
|
||||
|
||||
def clean_privacy_policy_accepted(self):
|
||||
val = self.cleaned_data.get('privacy_policy_accepted')
|
||||
if not val and self.instance.privacy_policy:
|
||||
raise forms.ValidationError(
|
||||
ugettext(u'Wir müssen deine Daten leider speichern können,'
|
||||
u' damit wir wissen, dass du dich angemeldet hast.'),
|
||||
code='privacy_policy_not_accepted',
|
||||
)
|
||||
return val
|
||||
Reference in New Issue
Block a user