From 2f12c577b41ce755438f3274f7af88f0adcbc558 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 10 Nov 2020 18:51:13 +0100 Subject: [PATCH 1/4] bug fix --- rowers/plannedsessions.py | 8 +- .../templates/fastestvirtualeventcreate.html | 117 ++++++++++++++++++ 2 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 rowers/templates/fastestvirtualeventcreate.html diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 03e34e0a..888ccb47 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -407,7 +407,7 @@ def add_workouts_plannedsession(ws,ps,r): duration = to_time(1000.*fastest_milliseconds) record = CourseTestResult( - userid=w.user.id, + userid=w.user.user.id, plannedsession = ps, duration = duration, coursecompleted = True, @@ -418,7 +418,7 @@ def add_workouts_plannedsession(ws,ps,r): record.save() else: record = CourseTestResult( - userid = w.user.id, + userid = w.user.user.id, workoutid=w.id, plannedsession = ps, duration = dt.time(0,0), @@ -438,7 +438,7 @@ def add_workouts_plannedsession(ws,ps,r): duration = dt.time(0,ps.sessionvalue) record = CourseTestResult( - userid=w.user.id, + userid=w.user.user.id, workoutid=w.id, plannedsession = ps, duration = duration, @@ -448,7 +448,7 @@ def add_workouts_plannedsession(ws,ps,r): record.save() else: record = CourseTestResult( - userid = w.user.id, + userid = w.user.user.id, plannedsession = ps, workoutid=w.id, duration = dt.time(0,ps.sessionvalue), diff --git a/rowers/templates/fastestvirtualeventcreate.html b/rowers/templates/fastestvirtualeventcreate.html new file mode 100644 index 00000000..7034c3f3 --- /dev/null +++ b/rowers/templates/fastestvirtualeventcreate.html @@ -0,0 +1,117 @@ +{% extends "newbase.html" %} +{% load staticfiles %} +{% load rowerfilters %} + +{% block title %}New Virtual Challenge{% endblock %} + +{% block main %} + +

New On-The-Water Virtual Challenge

+ +
    +
  • +

    With this form, you can create a new virtual challenge. After you submit + the form, the challenge is created and will be visible to all users. From + that moment, only the site admin can delete the challenge + (admin@rowsandall.com). You can still edit the challenge until + the start of the challenge window. +

    +
  • + +
  • +
    + {% if form.errors %} +

    + Please correct the error{{ form.errors|pluralize }} below. +

    + {% endif %} +

    + + {{ form.as_table }} +
    +

    +

    + {% csrf_token %} + +

    +
    +
  • +
  • +

    +

      +

      All times are local times in the time zone you select

      +

      Adding a contact phone number and email is not mandatory, but we + strongly recommend it.

      +

      If your event has a registration closure deadline, participants + have to enter (and can withdraw) before the registration closure time.

      +

      Participants can submit results until the evaluation closure time.

      +

      Until one hour after evaluation closure time, the challenge organizer + can review and reject submitted results ("disqualification"). If + you as the challenge organizer intend to use this functionality, it + is strongly recommended that you fill out a contact email or phone + number. +

      +

      + The participants can row this challenge on any course, and their fastest time + over the challenge distance (respectively the largest distance achieved over the + challenge duration) is automatically extracted from the workout. No + need to program a set piece. +

      +

      + 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. +

      +
    +

    +
  • +
+ + +{% endblock %} + +{% block scripts %} + + +{% endblock %} + +{% block sidebar %} +{% include 'menu_racing.html' %} +{% endblock %} From 99c081c67e862ad385f94434f328fe7ede101903 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 10 Nov 2020 19:12:17 +0100 Subject: [PATCH 2/4] delted --- rowers/plannedsessions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 888ccb47..4ab8ab0e 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -397,6 +397,9 @@ def add_workouts_plannedsession(ws,ps,r): if ps.sessiontype == 'fastest_distance': records = CourseTestResult.objects.filter(userid=w.user.id,plannedsession=ps) for record in records: + w1 = Workout.objects.get(id=record.workoutid) + w1.plannedsession = None + w1.save() record.delete() df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[w.id]) @@ -429,6 +432,9 @@ def add_workouts_plannedsession(ws,ps,r): if ps.sessiontype == 'fastest_time': records = CourseTestResult.objects.filter(userid=w.user.id,plannedsession=ps) for record in records: + w1 = Workout.objects.get(id=record.workoutid) + w1.plannedsession = None + w1.save() record.delete() df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[w.id]) From a5f0ce5b8408f9190e1fa804c465b064de992f69 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 10 Nov 2020 19:20:52 +0100 Subject: [PATCH 3/4] fix --- rowers/plannedsessions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 4ab8ab0e..6f707c46 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -406,6 +406,8 @@ def add_workouts_plannedsession(ws,ps,r): fastest_milliseconds = datautils.getfastest(df,ps.sessionvalue,mode='distance') if fastest_milliseconds > 0: + w.plannedsession = ps + w.save() duration = to_time(1000.*fastest_milliseconds) @@ -441,6 +443,8 @@ def add_workouts_plannedsession(ws,ps,r): fastest_meters = datautils.getfastest(df,ps.sessionvalue,mode='time') if fastest_meters > 0: + w.plannedsession = ps + w.save() duration = dt.time(0,ps.sessionvalue) record = CourseTestResult( From c230dd6e1bc9cb1b6ceadfbf71af56c108af53ac Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 10 Nov 2020 19:26:53 +0100 Subject: [PATCH 4/4] fix --- rowers/plannedsessions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 6f707c46..b4ddb230 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -720,7 +720,7 @@ def is_session_complete_ws(ws,ps): return ratio,'partial',completiondate return (0,'partial',None) elif ps.sessiontype in ['fastest_time','fastest_distance']: - vs = CourseTestResult.objects.filter(plannedsession=ps,userid=ws[0].user.id) + vs = CourseTestResult.objects.filter(plannedsession=ps,userid=ws[0].user.user.id) completiondate = ws.reverse()[0].date wids = [w.id for w in ws] for record in vs: