Private
Public Access
1
0

some refinements

This commit is contained in:
Sander Roosendaal
2020-05-27 09:22:09 +02:00
parent 11685f3126
commit eb41a5f17f
3 changed files with 30 additions and 10 deletions

View File

@@ -66,16 +66,28 @@ def save_scoring(name,user,filename,id=0,notes=""):
try: try:
sex = row['Gender'] sex = row['Gender']
if sex.lower() in ['m','men','male','open']:
sex = 'male'
elif sex.lower() in ['mix','mixed']:
sex = 'mixed'
else:
sex = 'female'
except KeyError: except KeyError:
sex = 'F' sex = 'female'
try: try:
weightclass = row['WeightClass'] weightclass = row['WeightClass']
if weightclass.lower() in ['hwt','h','o','heavy','open']:
weightclass = 'hwt'
elif weightclass.lower() in ['lwt','l','light','lights','lighties']:
weightclass = 'lwt'
except KeyError: except KeyError:
weightclass = 'hwt' weightclass = 'hwt'
try: try:
adaptiveclass = row['AdaptiveClass'] adaptiveclass = row['AdaptiveClass']
if adaptiveclass.lower() in ['o','open','none','no']:
adaptiveclass = None
except KeyError: except KeyError:
adaptiveclass = None adaptiveclass = None

View File

@@ -36,11 +36,14 @@
mixed gender crew (except for 1x where this check box does nothing). mixed gender crew (except for 1x where this check box does nothing).
</p> </p>
{% if race.coursestandards %} {% if race.coursestandards %}
<p>This race uses standard times and limits the race fields to those where <p>This race uses standard times and limits the race groups to those where
standard times exist. The "Field" form choice will overrule other selections you standard times exist. The "Field" form choice will overrule other selections you
make in the form (boat type, weight, etc) and your entry will be rejected make in the form (boat type, weight, etc) and your entry will be rejected
if the age and gender doesn't match. if the age and gender doesn't match.
</p> </p>
<p>
You can check the valid race groups and standard times <a target="_" href="/rowers/standards/{{ race.coursestandards.id }}/">here</a>.
</p>
{% endif %} {% endif %}
<div class="grid_6 alpha"> <div class="grid_6 alpha">
<table width="100%"> <table width="100%">

View File

@@ -292,11 +292,11 @@ def standard_view(request,id=0):
if orderby is not None: if orderby is not None:
standards = CourseStandard.objects.filter( standards = CourseStandard.objects.filter(
standardcollection=collection standardcollection=collection
).order_by(orderby,"-coursestandard","agemax","agemin","sex","name") ).order_by(orderby,"-referencespeed","agemax","agemin","sex","name")
else: else:
standards = CourseStandard.objects.filter( standards = CourseStandard.objects.filter(
standardcollection=collection standardcollection=collection
).order_by("-coursestandard","agemax","agemin","sex","name") ).order_by("-referencespeed","agemax","agemin","sex","name")
breadcrumbs = [ breadcrumbs = [
{ {
@@ -1596,6 +1596,11 @@ def virtualevent_register_view(request,id=0):
except VirtualRace.DoesNotExist: except VirtualRace.DoesNotExist:
raise Http404("Virtual Challenge does not exist") raise Http404("Virtual Challenge does not exist")
categories = None
if race.coursestandards is not None:
categories = CourseStandard.objects.filter(
standardcollection=race.coursestandards).order_by("name")
if not race_can_register(r,race): if not race_can_register(r,race):
messages.error(request,"You cannot register for this race") messages.error(request,"You cannot register for this race")
@@ -1609,7 +1614,7 @@ def virtualevent_register_view(request,id=0):
# we're still here # we're still here
if request.method == 'POST': if request.method == 'POST':
# process form # process form
form = VirtualRaceResultForm(request.POST) form = VirtualRaceResultForm(request.POST,categories=categories)
if form.is_valid(): if form.is_valid():
cd = form.cleaned_data cd = form.cleaned_data
teamname = cd['teamname'] teamname = cd['teamname']
@@ -1640,7 +1645,7 @@ def virtualevent_register_view(request,id=0):
referencespeed = coursestandard.referencespeed referencespeed = coursestandard.referencespeed
boattype = coursestandard.boattype boattype = coursestandard.boattype
boatclass = coursestandard.boatclass boatclass = coursestandard.boatclass
weightcategory = coursestandard.weightcategory weightcategory = coursestandard.weightclass
adaptiveclass = coursestandard.adaptiveclass adaptiveclass = coursestandard.adaptiveclass
skillclass = coursestandard.skillclass skillclass = coursestandard.skillclass
@@ -1649,19 +1654,19 @@ def virtualevent_register_view(request,id=0):
if age < coursestandard.agemin: if age < coursestandard.agemin:
messages.error(request,'You are younger than the minimum age for this group') messages.error(request,'You are younger than the minimum age for this group')
return HttpResponseRedirect(url) return HttpResponseRedirect(returnurl)
if age > coursestandard.agemax: if age > coursestandard.agemax:
messages.error(request,'You are older than the maximum age for this group') messages.error(request,'You are older than the maximum age for this group')
return HttpResponseRedirect(url) return HttpResponseRedirect(returnurl)
if sex == 'male' and coursestandard.sex != 'male': if sex == 'male' and coursestandard.sex != 'male':
messages.error(request,'Men are not allowed to enter this category') messages.error(request,'Men are not allowed to enter this category')
return HttpResponseRedirect(url) return HttpResponseRedirect(returnurl)
if sex == 'mixed' and coursestandard.sex not in ['mixed','male']: if sex == 'mixed' and coursestandard.sex not in ['mixed','male']:
messages.error(request,'Mixed crews are not allowed to enter this category') messages.error(request,'Mixed crews are not allowed to enter this category')
return HttpResponseRedirect(url) return HttpResponseRedirect(returnurl)