Private
Public Access
1
0

working MPV

This commit is contained in:
Sander Roosendaal
2021-10-08 16:24:58 +02:00
parent b497449846
commit e604350e23
9 changed files with 401 additions and 54 deletions

View File

@@ -1472,30 +1472,36 @@ class RaceResultFilterForm(forms.Form):
entrycategory = forms.MultipleChoiceField(
choices = [],
label = 'Groups',
widget=forms.CheckboxSelectMultiple()
widget=forms.CheckboxSelectMultiple(),
required=False,
)
def __init__(self, *args, **kwargs):
if 'records' in kwargs:
records = kwargs.pop('records',None)
records = kwargs.pop('records',None)
groups = kwargs.pop('groups',None)
super(RaceResultFilterForm,self).__init__(*args,**kwargs)
if records:
# group
thecategories = [record.entrycategory for record in records]
thecategories = list(set(thecategories))
if len(thecategories) <= 1:
del self.fields['entrycategory']
if groups:
thecategories = [record.entrycategory for record in records]
thecategories = list(set(thecategories))
if len(thecategories) <= 1:
del self.fields['entrycategory']
else:
categorychoices = []
for category in thecategories:
if category is not None:
categorychoices.append(
(category.id,category)
)
self.fields['entrycategory'].choices = categorychoices
self.fields['entrycategory'].initial = [cat[0] for cat in categorychoices]
else:
categorychoices = []
for category in thecategories:
if category is not None:
categorychoices.append(
(category.id,category)
)
self.fields['entrycategory'].choices = categorychoices
self.fields['entrycategory'].initial = [cat[0] for cat in categorychoices]
del self.fields['entrycategory']
# sex
thesexes = [record.sex for record in records]