From eb41a5f17fec77a5f152b00662cd785bf8fd0715 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 27 May 2020 09:22:09 +0200 Subject: [PATCH] some refinements --- rowers/scoring.py | 14 +++++++++++++- rowers/templates/virtualeventregister.html | 5 ++++- rowers/views/racesviews.py | 21 +++++++++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/rowers/scoring.py b/rowers/scoring.py index 89de6745..b196b8f5 100644 --- a/rowers/scoring.py +++ b/rowers/scoring.py @@ -66,16 +66,28 @@ def save_scoring(name,user,filename,id=0,notes=""): try: 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: - sex = 'F' + sex = 'female' try: 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: weightclass = 'hwt' try: adaptiveclass = row['AdaptiveClass'] + if adaptiveclass.lower() in ['o','open','none','no']: + adaptiveclass = None except KeyError: adaptiveclass = None diff --git a/rowers/templates/virtualeventregister.html b/rowers/templates/virtualeventregister.html index 4752256c..20159a4e 100644 --- a/rowers/templates/virtualeventregister.html +++ b/rowers/templates/virtualeventregister.html @@ -36,11 +36,14 @@ mixed gender crew (except for 1x where this check box does nothing).

{% if race.coursestandards %} -

This race uses standard times and limits the race fields to those where +

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 make in the form (boat type, weight, etc) and your entry will be rejected if the age and gender doesn't match.

+

+ You can check the valid race groups and standard times here. +

{% endif %}
diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py index 5124e421..9603465c 100644 --- a/rowers/views/racesviews.py +++ b/rowers/views/racesviews.py @@ -292,11 +292,11 @@ def standard_view(request,id=0): if orderby is not None: standards = CourseStandard.objects.filter( standardcollection=collection - ).order_by(orderby,"-coursestandard","agemax","agemin","sex","name") + ).order_by(orderby,"-referencespeed","agemax","agemin","sex","name") else: standards = CourseStandard.objects.filter( standardcollection=collection - ).order_by("-coursestandard","agemax","agemin","sex","name") + ).order_by("-referencespeed","agemax","agemin","sex","name") breadcrumbs = [ { @@ -1596,6 +1596,11 @@ def virtualevent_register_view(request,id=0): except VirtualRace.DoesNotExist: 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): messages.error(request,"You cannot register for this race") @@ -1609,7 +1614,7 @@ def virtualevent_register_view(request,id=0): # we're still here if request.method == 'POST': # process form - form = VirtualRaceResultForm(request.POST) + form = VirtualRaceResultForm(request.POST,categories=categories) if form.is_valid(): cd = form.cleaned_data teamname = cd['teamname'] @@ -1640,7 +1645,7 @@ def virtualevent_register_view(request,id=0): referencespeed = coursestandard.referencespeed boattype = coursestandard.boattype boatclass = coursestandard.boatclass - weightcategory = coursestandard.weightcategory + weightcategory = coursestandard.weightclass adaptiveclass = coursestandard.adaptiveclass skillclass = coursestandard.skillclass @@ -1649,19 +1654,19 @@ def virtualevent_register_view(request,id=0): if age < coursestandard.agemin: messages.error(request,'You are younger than the minimum age for this group') - return HttpResponseRedirect(url) + return HttpResponseRedirect(returnurl) if age > coursestandard.agemax: 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': 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']: messages.error(request,'Mixed crews are not allowed to enter this category') - return HttpResponseRedirect(url) + return HttpResponseRedirect(returnurl)