From ef1f9a88bbb841822367e9d7b4cb7bc6b1b716db Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 23 Feb 2020 10:24:24 +0100 Subject: [PATCH] bug fixes in summary edit --- rowers/tests/test_aworkouts.py | 5 +++++ rowers/views/workoutviews.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rowers/tests/test_aworkouts.py b/rowers/tests/test_aworkouts.py index 55d48c5d..dab07b99 100644 --- a/rowers/tests/test_aworkouts.py +++ b/rowers/tests/test_aworkouts.py @@ -564,6 +564,9 @@ class WorkoutViewTest(TestCase): 'value_pace':'2:23', 'value_power':'200', 'value_work':'400', + 'value_spm':'20', + 'activeminutesmin':'0', + 'activeminutesmax':'60', 'savepowerpaceform':True, } @@ -582,6 +585,8 @@ class WorkoutViewTest(TestCase): 'power': 200, 'pace': '2:30', 'work': 400, + 'activeminutesmin':'0', + 'activeminutesmax': '60', } form = PowerIntervalUpdateForm(form_data) diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index df4e0705..ab9e747c 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -5676,8 +5676,15 @@ def workout_summary_edit_view(request,id,message="",successmessage="" value_spm = request.POST['value_spm'] activeminutesmin = request.POST['activeminutesmin'] activeminutesmax = request.POST['activeminutesmax'] - activesecondsmin = 60.*activeminutesmin - activesecondsmax = 60.*activeminutesmax + try: + activesecondsmin = 60.*float(activeminutesmin) + activesecondsmax = 60.*float(activeminutesmax) + except ValueError: + activesecondsmin = 0 + activeminutesmin = 0 + activeminutesmax = maxminutes + activesecondsmax = rowdata.duration + if abs(rowdata.duration-activesecondsmax) < 60.: activesecondsmax = rowdata.duration if powerorpace == 'power':