Private
Public Access
1
0

added adaptive classes (not tested)

This commit is contained in:
Sander Roosendaal
2018-12-15 14:18:48 +01:00
parent cc2d82cf56
commit 2ffd145bca
9 changed files with 122 additions and 10 deletions

View File

@@ -575,6 +575,8 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
('lwt','light-weight'),
)
adaptivecategories = mytypes.adaptivetypes
thisyear = timezone.now().year
birthdate = forms.DateTimeField(
@@ -597,6 +599,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'
@@ -887,6 +892,7 @@ class RaceResultFilterForm(forms.Form):
('lwt','light-weight'),
)
adaptivecategories = mytypes.adaptivetypes
sex = forms.MultipleChoiceField(
choices=sexchoices,
@@ -915,6 +921,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)
@@ -976,7 +988,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',