Better age check
This commit is contained in:
@@ -49,10 +49,12 @@ class MembershipForm(forms.ModelForm):
|
|||||||
self.add_error(fieldname, errormsg)
|
self.add_error(fieldname, errormsg)
|
||||||
if membership and cleaned_data.get('birthday'):
|
if membership and cleaned_data.get('birthday'):
|
||||||
birthday = cleaned_data.get('birthday')
|
birthday = cleaned_data.get('birthday')
|
||||||
print("Today:", date.today())
|
today = date.today()
|
||||||
print("Birthday:", birthday)
|
age = today.year - birthday.year - (
|
||||||
if date.today().year - cleaned_data.get('birthday').year < 16:
|
(today.month, today.day) < (birthday.month, birthday.day))
|
||||||
self.add_error('birthday', 'Midestalter für Mitlieder ist 16 Jahre!')
|
if age < 16:
|
||||||
|
self.add_error('birthday',
|
||||||
|
'Midestalter für Mitlieder ist 16 Jahre!')
|
||||||
|
|
||||||
|
|
||||||
class RegistrationForm(MembershipForm):
|
class RegistrationForm(MembershipForm):
|
||||||
|
|||||||
Reference in New Issue
Block a user