Private
Public Access
1
0

Merge branch 'develop' into feature/braintree

This commit is contained in:
Sander Roosendaal
2018-12-15 15:52:01 +01:00
10 changed files with 142 additions and 18 deletions

View File

@@ -579,6 +579,8 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
('lwt','light-weight'),
)
adaptivecategories = mytypes.adaptivetypes
thisyear = timezone.now().year
birthdate = forms.DateTimeField(
@@ -592,6 +594,7 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
age = (timezone.now() - dob).days/365
if age < 16:
raise forms.ValidationError('Must be at least 16 years old to register')
return self.cleaned_data['birthdate']
sex = forms.ChoiceField(required=True,
choices=sexcategories,
@@ -601,6 +604,9 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
weightcategory = forms.ChoiceField(label='Weight Category',
choices=weightcategories)
adaptiveclass = forms.ChoiceField(label='Adaptive Classification',
choices=adaptivecategories)
# def __init__(self, *args, **kwargs):
# self.fields['sex'].initial = 'not specified'
@@ -891,6 +897,7 @@ class RaceResultFilterForm(forms.Form):
('lwt','light-weight'),
)
adaptivecategories = mytypes.adaptivetypes
sex = forms.MultipleChoiceField(
choices=sexchoices,
@@ -919,6 +926,12 @@ class RaceResultFilterForm(forms.Form):
initial=['hwt','lwt'],
widget=forms.CheckboxSelectMultiple())
adaptivecategory = forms.MultipleChoiceField(
choices=adaptivecategories,
label='Adaptive Class',
initial=['None','PR1','PR2','PR3','FES'],
widget=forms.CheckboxSelectMultiple())
def __init__(self, *args, **kwargs):
if 'records' in kwargs:
records = kwargs.pop('records',None)
@@ -980,7 +993,20 @@ class RaceResultFilterForm(forms.Form):
if choice[0] in theweightcategoryes:
weightcategorychoices.append(choice)
self.fields['weightcategory'].choices = weightcategorychoices
# adaptivecategory
theadaptivecategoryes = [record.adaptiveclass for record in records]
theadaptivecategoryes = list(set(theadaptivecategoryes))
if len(theadaptivecategoryes)<= 1:
del self.fields['adaptivecategory']
else:
adaptivecategorychoices = []
for choice in self.fields['adaptivecategory'].choices:
if choice[0] in theadaptivecategoryes:
adaptivecategorychoices.append(choice)
self.fields['adaptivecategory'].choices = adaptivecategorychoices
class WorkoutRaceSelectForm(forms.Form):
# evaluate_after = forms.TimeField(
# input_formats=['%H:%M:%S.%f',