Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2020-11-14 13:04:20 +01:00
parent 0113c096ce
commit 45add21210
3 changed files with 24 additions and 5 deletions

View File

@@ -3253,6 +3253,11 @@ class IndoorVirtualRaceResult(models.Model):
max_length=40,
default='rower',
verbose_name = 'Ergometer Class')
boattype = models.CharField(choices=boattypes,max_length=40,
default='1x',
verbose_name = 'Boat Type'
)
coursecompleted = models.BooleanField(default=False)
sex = models.CharField(default="not specified",
max_length=30,

View File

@@ -1470,7 +1470,7 @@ def default_class(r,w,race):
adaptiveclass = w.adaptiveclass
weightclass = w.weightcategory
else:
if race.sessiontype == 'race':
if race.sessiontype in ['race','fastest_time','fastest_meters']:
boatclass = 'water'
else:
boatclass = 'rower'
@@ -1486,9 +1486,11 @@ def default_class(r,w,race):
boattype=boattype,
weightclass=weightclass,
sex=sex,
standardcollection = race.coursestandards,
).order_by("agemax","-agemin","boattype","sex")
if standards.count()==0:
# omit weight
standards = CourseStandard.objects.filter(
@@ -1497,33 +1499,41 @@ def default_class(r,w,race):
adaptiveclass=adaptiveclass,
boattype=boattype,
sex=sex,
standardcollection = race.coursestandards,
).order_by(
"agemax","-agemin","boattype","sex","weightclass",
"referencespeed"
)
if standards.count()==0:
# omit adaptive class
standards = CourseStandard.objects.filter(
agemin__lt=age,agemax__gt=age,
boattype=boattype,sex=sex,
standardcollection = race.coursestandards,
).order_by(
"agemax","-agemin","boattype","sex",
"weightclass","referencespeed")
if standards.count()==0:
# omit boattype
standards = CourseStandard.objects.filter(
agemin__lt=age,agemax__gt=age,sex=sex,
standardcollection = race.coursestandards,
).order_by(
"agemax","-agemin","boattype","sex",
"weightclass","referencespeed")
if standards.count()==0:
# omit boattype
standards = CourseStandard.objects.filter(
agemin__lt=age,agemax__gt=age,sex='male',
standardcollection = race.coursestandards
).order_by(
"agemax","-agemin","boattype","sex",
"weightclass","referencespeed")
if standards.count()==0:
# boolean, boattype, boatclass, adaptiveclass, weightclass, sex, coursestandard,
return False,'1x','water',None,'hwt','male',5.0,None

View File

@@ -1325,7 +1325,6 @@ def virtualevent_view(request,id=0):
records = resultobj.objects.filter(race=race)
buttons = []
# to-do - add DNS
@@ -2055,6 +2054,7 @@ def virtualevent_register_view(request,id=0):
categories = None
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,referencespeed,initialcategory = default_class(r,None,race)
if race.coursestandards is not None:
categories = CourseStandard.objects.filter(
standardcollection=race.coursestandards).order_by("name")
@@ -2069,6 +2069,11 @@ def virtualevent_register_view(request,id=0):
return HttpResponseRedirect(url)
if race.sessiontype == 'race':
resultobj = VirtualRaceResult
else:
resultobj = IndoorVirtualRaceResult
# we're still here
if request.method == 'POST':
# process form
@@ -2129,7 +2134,7 @@ def virtualevent_register_view(request,id=0):
record = VirtualRaceResult(
record = resultobj(
userid=r.id,
teamname=teamname,
race=race,
@@ -3320,7 +3325,7 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
if selectedworkout is not None:
workouts = Workout.objects.filter(id=selectedworkout)
if race.sessiontype == 'race':
result,comments,errors,jobid = add_workout_race(
workouts,race,r,
@@ -3616,7 +3621,6 @@ def virtualevent_entry_edit_view(request,id=0,entryid=0):
messages.error(request,'You are older than the maximum age for this group')
return HttpResponseRedirect(returnurl)
print(sex,coursestandard.sex)
if sex == 'male' and coursestandard.sex != 'male':
messages.error(request,'Men are not allowed to enter this category')
return HttpResponseRedirect(returnurl)