diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 0edb75eb..14efce52 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -1142,6 +1142,12 @@ def update_indoorvirtualrace(ps,cd): ps.timezone = timezone_str + if ps.sessiontype == 'fastest_distance': + ps.approximate_distance = ps.sessionvalue + + if ps.course is not None: + ps.approximate_distance = ps.course.distance + ps.save() return 1,'Virtual Race Updated' @@ -1195,6 +1201,12 @@ def update_virtualrace(ps,cd): ps.timezone = timezone_str + if ps.sessiontype == 'fastest_distance': + ps.approximate_distance = ps.sessionvalue + + if ps.course is not None: + ps.approximate_distance = ps.course.distance + ps.save() return 1,'Virtual Race Updated' @@ -1685,6 +1697,7 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): ids = [w.id for w in ws] ids = list(set(ids)) + if len(ids)>1 and race.sessiontype in ['test','coursetest','race','indoorrace','fastest_time','fastest_distance']: # pragma: no cover errors.append('For tests, you can only attach one workout') return result,comments,errors,0 @@ -1725,10 +1738,12 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): errors.append("Couldn't find this entry") return result,comments,errors,0 + + records = IndoorVirtualRaceResult.objects.filter( userid=r.id, race=race, - workoutid = ws[0].id + #workoutid = ws[0].id ) if ws[0].workouttype != record.boatclass: # pragma: no cover @@ -1757,8 +1772,14 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): errors.append('Workout %i did not match the race window' % ws[0].id) return result,comments,errors,0 + if result>0: for otherrecord in records: # pragma: no cover + oldworkouts = Workout.objects.filter(plannedsession=race) + for oldworkout in oldworkouts: + oldworkout.plannedsession = None + oldworkout.save() + otherrecord.workoutid = None otherrecord.coursecompleted = False otherrecord.save() diff --git a/rowers/templates/analysis.html b/rowers/templates/analysis.html index d19304a9..b1e8ea47 100644 --- a/rowers/templates/analysis.html +++ b/rowers/templates/analysis.html @@ -82,7 +82,7 @@
- BETA: Box Chart Statistics of stroke metrics over a date range + Box Chart Statistics of stroke metrics over a date range
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 40543d22..e47a5f9e 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -255,7 +255,15 @@