From 66454b9ba2e2c26c64c7e8e586f5165b29ae188a Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 26 May 2020 20:55:50 +0200 Subject: [PATCH] adding Standard Times to events --- rowers/migrations/0001_initial.py | 2 +- rowers/models.py | 7 ++++++- rowers/templates/indoorvirtualeventcreate.html | 9 +++++++++ rowers/templates/virtualevent.html | 16 ++++++++++++++++ rowers/templates/virtualeventcreate.html | 9 +++++++++ rowers/views/racesviews.py | 16 +++++++++++++++- 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/rowers/migrations/0001_initial.py b/rowers/migrations/0001_initial.py index ee6b4a02..95afc7b0 100644 --- a/rowers/migrations/0001_initial.py +++ b/rowers/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.1.7 on 2020-05-26 18:13 +# Generated by Django 2.1.7 on 2020-05-26 18:20 import datetime from django.conf import settings diff --git a/rowers/models.py b/rowers/models.py index e57a9793..c84f98a9 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2262,7 +2262,8 @@ class VirtualRace(PlannedSession): contact_email = models.EmailField(max_length=254, validators=[validate_email],blank=True) - coursestandards = models.ForeignKey(StandardCollection,null=True,on_delete=models.SET_NULL) + coursestandards = models.ForeignKey(StandardCollection,null=True,on_delete=models.SET_NULL, + verbose_name='Standard Times') def __str__(self): @@ -2432,6 +2433,7 @@ class IndoorVirtualRaceForm(ModelForm): 'registration_closure', 'evaluation_closure', 'comment', + 'coursestandards', 'contact_phone', 'contact_email', ] @@ -2568,6 +2570,7 @@ class VirtualRaceForm(ModelForm): 'registration_closure', 'evaluation_closure', 'course', + 'coursestandards', 'comment', 'contact_phone', 'contact_email', @@ -2939,6 +2942,7 @@ class VirtualRaceResult(models.Model): race = models.ForeignKey(VirtualRace,on_delete=models.CASCADE) duration = models.TimeField(default=datetime.time(1,0)) distance = models.IntegerField(default=0) + points = models.IntegerField(default=0) boatclass = models.CharField(choices=boatclasses, max_length=40, default='water', @@ -3002,6 +3006,7 @@ class IndoorVirtualRaceResult(models.Model): race = models.ForeignKey(VirtualRace,on_delete=models.CASCADE) duration = models.TimeField(default=datetime.time(1,0)) distance = models.IntegerField(default=0) + points = models.IntegerField(default=0) boatclass = models.CharField(choices=boatclasses, max_length=40, default='rower', diff --git a/rowers/templates/indoorvirtualeventcreate.html b/rowers/templates/indoorvirtualeventcreate.html index 2fcc477b..8ec29004 100644 --- a/rowers/templates/indoorvirtualeventcreate.html +++ b/rowers/templates/indoorvirtualeventcreate.html @@ -55,6 +55,15 @@ If you require a screenshot of the PM monitor, do mention this in the comment.

+

+ Standard Times are a way to compare results in a race category with + a course record or golden standard for that event. A point score is calculated + which compares the participant's result with the standard. This offers an + engaging way to compete on points across different categories, boat types, and skill + levels. + If you select a Standard Times set from the drop-down list, race categories will + be limited to those in the selected set of Standard Times. +

diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index b3e1ff57..3589b469 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -104,6 +104,11 @@ Challenge Time Zone{{ race.timezone }} {% endif %} + {% if race.coursestandards %} + + Standard Times{{ race.coursestandards }} + + {% endif %} {{ race.sessionmode }} challenge @@ -541,6 +546,17 @@ review and reject entries. If you are disqualified in this way, you will receive an email with the reason.

+ {% if race.coursestandards %} +

+ Standard Times are a way to compare results in a race category with + a course record or golden standard for that event. A point score is calculated + which compares the participant's result with the standard. This offers an + engaging way to compete on points across different categories, boat types, and skill + levels. + If you select a Standard Times set from the drop-down list, race categories will + be limited to those in the selected set of Standard Times. +

+ {% endif %} diff --git a/rowers/templates/virtualeventcreate.html b/rowers/templates/virtualeventcreate.html index c26e54c2..6bd65d53 100644 --- a/rowers/templates/virtualeventcreate.html +++ b/rowers/templates/virtualeventcreate.html @@ -49,6 +49,15 @@ is strongly recommended that you fill out a contact email or phone number.

+

+ Standard Times are a way to compare results in a race category with + a course record or golden standard for that event. A point score is calculated + which compares the participant's result with the standard. This offers an + engaging way to compete on points across different categories, boat types, and skill + levels. + If you select a Standard Times set from the drop-down list, race categories will + be limited to those in the selected set of Standard Times. +

diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py index 700adfac..95bf3eb0 100644 --- a/rowers/views/racesviews.py +++ b/rowers/views/racesviews.py @@ -529,6 +529,11 @@ def standards_upload_view(request,id=0): is_ajax = True r = getrower(request.user) + if id != 0: + collection = StandardCollection.objects.get(id=id) + if request.user != collection.manager: + raise PermissionDenied("You cannot change this set of time standards") + if request.method == 'POST': form = StandardsForm(request.POST,request.FILES) @@ -573,6 +578,12 @@ def standards_upload_view(request,id=0): else: if not is_ajax: form = StandardsForm() + if id != 0: + collection = StandardCollection.objects.get(id=id) + form = StandardsForm(initial={ + 'name':collection.name, + 'notes': collection.notes, + }) return render(request,'standard_form.html', {'form':form, 'active':'nav-racing', @@ -655,7 +666,6 @@ def virtualevents_view(request): country__in=countries ).order_by("startdate","start_time") else: - form = VirtualRaceSelectForm() if is_ajax: @@ -1938,6 +1948,7 @@ def indoorvirtualevent_create_view(request): evaluation_closure = cd['evaluation_closure'] contact_phone = cd['contact_phone'] contact_email = cd['contact_email'] + coursestandards = cd['coursestandards'] # correct times @@ -1992,6 +2003,7 @@ def indoorvirtualevent_create_view(request): sessionvalue = sessionvalue, course=None, timezone=timezone_str, + coursestandards=coursestandards, evaluation_closure=evaluation_closure, registration_closure=registration_closure, contact_phone=contact_phone, @@ -2078,6 +2090,7 @@ def virtualevent_create_view(request): evaluation_closure = cd['evaluation_closure'] contact_phone = cd['contact_phone'] contact_email = cd['contact_email'] + coursestandards = cd['coursestandards'] # correct times @@ -2129,6 +2142,7 @@ def virtualevent_create_view(request): evaluation_closure=evaluation_closure, registration_closure=registration_closure, contact_phone=contact_phone, + coursestandards=coursestandards, contact_email=contact_email, country = course.country, manager=request.user,