From 1604768ada098bb4f77710293c185267bd53849a Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 1 Jan 2018 15:01:32 +0100 Subject: [PATCH] added option to switch off fast calc --- rowers/models.py | 4 +++- rowers/tasks.py | 19 ++++++++++++------- rowers/templates/otwsetpower.html | 4 ++++ rowers/views.py | 6 +++++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index 8e024c1d..c4495b5b 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -875,9 +875,11 @@ class WorkoutForm(ModelForm): # Used for the rowing physics calculations class AdvancedWorkoutForm(ModelForm): + quick_calc = forms.BooleanField(initial=True,required=False) + class Meta: model = Workout - fields = ['boattype','weightvalue'] + fields = ['boattype','weightvalue','quick_calc'] class RowerExportForm(ModelForm): class Meta: diff --git a/rowers/tasks.py b/rowers/tasks.py index cdd1f807..9f7c971d 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -356,10 +356,7 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,**kwargs): def handle_otwsetpower(self,f1, boattype, weightvalue, first_name, last_name, email, workoutid, **kwargs): -# ps=[ -# 1, 1, 1, 1], -# ratio=1.0, -# debug=False): + job = self.request job_id = job.id @@ -378,7 +375,12 @@ def handle_otwsetpower(self,f1, boattype, weightvalue, debug = kwargs['debug'] else: debug = False - + + if 'quick_calc' in kwargs: + usetable = kwargs['quick_calc'] + else: + usetable = False + kwargs['jobid'] = job_id @@ -416,8 +418,10 @@ def handle_otwsetpower(self,f1, boattype, weightvalue, pass progressurl = SITE_URL + siteurl = SITE_URL if debug: progressurl = SITE_URL_DEV + siteurl = SITE_URL_DEV secret = PROGRESS_CACHE_SECRET progressurl += "/rowers/record-progress/" @@ -431,7 +435,7 @@ def handle_otwsetpower(self,f1, boattype, weightvalue, powermeasured=powermeasured, progressurl=progressurl, secret=secret, - usetable=True,storetable=physics_cache, + usetable=usetable,storetable=physics_cache, ) # save data @@ -470,7 +474,8 @@ def handle_otwsetpower(self,f1, boattype, weightvalue, message += "Thank you for using rowsandall.com.\n\n" message += "Rowsandall OTW calculations have not been fully implemented yet.\n" message += "We are now running an experimental version for debugging purposes. \n" - message += "Your wind/stream corrected plot is available here: http://rowsandall.com/rowers/workout/" + message += "Your wind/stream corrected plot is available here: " + message += siteurl+"/rowers/workout/" message += str(workoutid) message += "/interactiveotwplot\n\n" message += "Please report any bugs/inconsistencies/unexpected results at rowsandall.slack.com or by reply to this email.\n\n" diff --git a/rowers/templates/otwsetpower.html b/rowers/templates/otwsetpower.html index 51218c6a..7a997bed 100644 --- a/rowers/templates/otwsetpower.html +++ b/rowers/templates/otwsetpower.html @@ -35,6 +35,10 @@ We use FISA minimum boat weight and standard rigging for our calculations.

+

The Quick calculation option potentially speeds up the calculation, + at the cost of a slight reduction in accuracy. It is recommended + to keep this option selected.

+
{% if form.errors %}

diff --git a/rowers/views.py b/rowers/views.py index dec96cc4..a19d7eeb 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -6728,12 +6728,14 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""): form = AdvancedWorkoutForm(request.POST) if form.is_valid(): + quick_calc = form.cleaned_data['quick_calc'] boattype = form.cleaned_data['boattype'] weightvalue = form.cleaned_data['weightvalue'] row.boattype = boattype row.weightvalue = weightvalue row.save() + # load row data & create power/wind/bearing columns if not set f1 = row.csvfilename rowdata = rdata(f1) @@ -6770,7 +6772,9 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""): weightvalue, first_name,last_name,emailaddress,id, ps=[r.p0,r.p1,r.p2,r.p3], - ratio=r.cpratio) + ratio=r.cpratio, + quick_calc = quick_calc, + ) try: request.session['async_tasks'] += [(job.id,'otwsetpower')]