diff --git a/rowers/models.py b/rowers/models.py index 4edafe77..ed96081a 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -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, diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 77cf6117..f95fa435 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -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 diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py index a2867ee3..d246f32a 100644 --- a/rowers/views/racesviews.py +++ b/rowers/views/racesviews.py @@ -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)