registration: add support for year of birth
Some checks failed
buildbot/tox Build done.

this is only in dav_registration for now. dav_events is following.
This commit is contained in:
2020-12-09 10:51:06 +01:00
parent 998b4cd5cf
commit 0ff559d548
6 changed files with 70 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import datetime
import logging
from django import forms
from django.utils.translation import ugettext, ugettext_lazy as _
@@ -25,6 +26,28 @@ class RegistrationForm(forms.ModelForm):
'note': forms.Textarea(attrs={'rows': 5}),
}
def clean_year_of_birth(self):
now = datetime.datetime.now()
year_now = now.year
max_age = 100
val = self.cleaned_data.get('year_of_birth')
if val > year_now:
raise forms.ValidationError(
ugettext(u'Dein Geburtsjahr liegt in der Zukunft?'
u' Das finden wir gut,'
u' aber bitte melde dich besser mal per E-Mail bei uns.'),
code='to_young',
)
elif val < (year_now - max_age):
raise forms.ValidationError(
ugettext(u'Du bist schon über %(max_age)d Jahre alt?'
u' Das finden wir gut,'
u' aber bitte melde dich besser mal per E-Mail bei uns.'),
params={'max_age': max_age},
code='to_old',
)
return val
def clean_experience(self):
val = self.cleaned_data.get('experience')
if val == '':