results filter on virtual race results
This commit is contained in:
@@ -702,7 +702,43 @@ class WorkoutSessionSelectForm(forms.Form):
|
|||||||
initial=workoutdata['initial'],
|
initial=workoutdata['initial'],
|
||||||
widget = forms.CheckboxSelectMultiple,
|
widget = forms.CheckboxSelectMultiple,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class RaceResultFilterForm(forms.Form):
|
||||||
|
sexchoices = (
|
||||||
|
('female','Female'),
|
||||||
|
('male','Male'),
|
||||||
|
('mixed','Mixed'),
|
||||||
|
)
|
||||||
|
|
||||||
|
weightcategories = (
|
||||||
|
('hwt','heavy-weight'),
|
||||||
|
('lwt','light-weight'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
sex = forms.MultipleChoiceField(
|
||||||
|
choices=sexchoices,
|
||||||
|
initial=['male','female','mixed'],
|
||||||
|
label='Gender',
|
||||||
|
widget=forms.CheckboxSelectMultiple())
|
||||||
|
|
||||||
|
boattype = forms.MultipleChoiceField(
|
||||||
|
choices=boattypes,
|
||||||
|
label='Boat Type',
|
||||||
|
initial=['1x','2x','2-','4x','4-','8+'],
|
||||||
|
widget=forms.CheckboxSelectMultiple())
|
||||||
|
|
||||||
|
age_min = forms.IntegerField(label='Min Age',initial=16)
|
||||||
|
age_max = forms.IntegerField(label='Max Age',initial=100)
|
||||||
|
|
||||||
|
weightcategory = forms.MultipleChoiceField(
|
||||||
|
choices=weightcategories,
|
||||||
|
label='Weight Category',
|
||||||
|
initial=['hwt','lwt'],
|
||||||
|
widget=forms.CheckboxSelectMultiple())
|
||||||
|
|
||||||
class WorkoutRaceSelectForm(forms.Form):
|
class WorkoutRaceSelectForm(forms.Form):
|
||||||
# evaluate_after = forms.TimeField(
|
# evaluate_after = forms.TimeField(
|
||||||
# input_formats=['%H:%M:%S.%f',
|
# input_formats=['%H:%M:%S.%f',
|
||||||
|
|||||||
@@ -230,10 +230,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 omega">
|
<div class="grid_4 omega">
|
||||||
|
<p>
|
||||||
<h2>Course</h2>
|
<h2>Course</h2>
|
||||||
{{ coursediv|safe }}
|
{{ coursediv|safe }}
|
||||||
|
|
||||||
{{ coursescript|safe }}
|
{{ coursescript|safe }}
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<h2>Filter Results</h2>
|
||||||
|
|
||||||
|
<form id="result_filter_form", method="post">
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% csrf_token %}
|
||||||
|
<input class="button green" type="submit" value="Submit">
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ from rowers.forms import (
|
|||||||
LandingPageForm,PlannedSessionSelectForm,WorkoutSessionSelectForm,
|
LandingPageForm,PlannedSessionSelectForm,WorkoutSessionSelectForm,
|
||||||
PlannedSessionTeamForm,PlannedSessionTeamMemberForm,
|
PlannedSessionTeamForm,PlannedSessionTeamMemberForm,
|
||||||
VirtualRaceSelectForm,WorkoutRaceSelectForm,CourseSelectForm,
|
VirtualRaceSelectForm,WorkoutRaceSelectForm,CourseSelectForm,
|
||||||
|
RaceResultFilterForm,
|
||||||
)
|
)
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
@@ -13439,6 +13440,7 @@ def virtualevent_view(request,id=0):
|
|||||||
else:
|
else:
|
||||||
r = None
|
r = None
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
race = VirtualRace.objects.get(id=id)
|
race = VirtualRace.objects.get(id=id)
|
||||||
except VirtualRace.DoesNotExist:
|
except VirtualRace.DoesNotExist:
|
||||||
@@ -13467,17 +13469,52 @@ def virtualevent_view(request,id=0):
|
|||||||
if race_can_edit(r,race):
|
if race_can_edit(r,race):
|
||||||
buttons += ['editbutton']
|
buttons += ['editbutton']
|
||||||
|
|
||||||
results = VirtualRaceResult.objects.filter(
|
if request.method == 'POST':
|
||||||
race=race,
|
form = RaceResultFilterForm(request.POST)
|
||||||
workoutid__isnull=False,
|
if form.is_valid():
|
||||||
).order_by("duration")
|
cd = form.cleaned_data
|
||||||
|
sex = cd['sex']
|
||||||
|
boattype = cd['boattype']
|
||||||
|
age_min = cd['age_min']
|
||||||
|
age_max = cd['age_max']
|
||||||
|
weightcategory = cd['weightcategory']
|
||||||
|
|
||||||
# to-do - add DNS
|
results = VirtualRaceResult.objects.filter(
|
||||||
dns = []
|
race=race,
|
||||||
if timezone.now() > race.evaluation_closure:
|
workoutid__isnull=False,
|
||||||
dns = VirtualRaceResult.objects.filter(
|
boattype__in=boattype,
|
||||||
|
sex__in=sex,
|
||||||
|
weightcategory__in=weightcategory,
|
||||||
|
age__gte=age_min,
|
||||||
|
age__lte=age_max
|
||||||
|
).order_by("duration")
|
||||||
|
|
||||||
|
# to-do - add DNS
|
||||||
|
dns = []
|
||||||
|
if timezone.now() > race.evaluation_closure:
|
||||||
|
dns = VirtualRaceResult.objects.filter(
|
||||||
|
race=race,
|
||||||
|
workoutid__isnull=True,
|
||||||
|
boattype__in=boattype,
|
||||||
|
sex__in=sex,
|
||||||
|
weightcategory__in=weightcategory,
|
||||||
|
age__gte=age_min,
|
||||||
|
age__lte=age_max
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
form = RaceResultFilterForm()
|
||||||
|
|
||||||
|
results = VirtualRaceResult.objects.filter(
|
||||||
race=race,
|
race=race,
|
||||||
workoutid__isnull=True,
|
workoutid__isnull=False,
|
||||||
|
).order_by("duration")
|
||||||
|
|
||||||
|
# to-do - add DNS
|
||||||
|
dns = []
|
||||||
|
if timezone.now() > race.evaluation_closure:
|
||||||
|
dns = VirtualRaceResult.objects.filter(
|
||||||
|
race=race,
|
||||||
|
workoutid__isnull=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -13497,6 +13534,7 @@ def virtualevent_view(request,id=0):
|
|||||||
'buttons':buttons,
|
'buttons':buttons,
|
||||||
'dns':dns,
|
'dns':dns,
|
||||||
'records':records,
|
'records':records,
|
||||||
|
'form':form,
|
||||||
})
|
})
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
|
|||||||
Reference in New Issue
Block a user