From d0455a97c031534471b8570daf9b25ec40d8f4b7 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 9 Jan 2018 13:29:37 +0100 Subject: [PATCH 1/2] bug fix in RowerForm cleaning up --- rowers/models.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index 5e0af42b..0a9a7eda 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1238,38 +1238,59 @@ class RowerForm(ModelForm): try: rest = self.cleaned_data['rest'] except: - rest = int(self.data['rest']) + try: + rest = int(self.data['rest']) + except ValueError: + rest = 0 try: ut2 = self.cleaned_data['ut2'] except: - ut2 = self.data['ut2'] + try: + ut2 = self.data['ut2'] + except ValueError: + ut2 = 0 try: ut1 = self.cleaned_data['ut1'] except: - ut1 = self.data['ut1'] + try: + ut1 = self.data['ut1'] + except ValueError: + ut1 = 0 try: at = self.cleaned_data['at'] except: - at = self.data['at'] + try: + at = self.data['at'] + except ValueError: + at = 0 try: an = self.cleaned_data['an'] except: - an = self.data['an'] + try: + an = self.data['an'] + except ValueError: + an = 0 try: tr = self.cleaned_data['tr'] except: - tr = self.data['tr'] + try: + tr = self.data['tr'] + except ValueError: + tr = 0 try: max = self.cleaned_data['max'] except: - max = self.data['max'] - + try: + max = self.data['max'] + except ValueError: + max = 0 + if rest>=ut2: raise forms.ValidationError("Resting heart rate should be lower than UT2") if ut2>=ut1: From e8ca3abe20f4ad04fa6787f15f7bc8e8fdc4d997 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 10 Jan 2018 20:30:43 +0100 Subject: [PATCH 2/2] added messaging on tasks status --- rowers/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rowers/views.py b/rowers/views.py index 7fc445ae..1e9abb42 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -4126,7 +4126,7 @@ def otwrankings_view(request,theuser=0, request.session['async_tasks'] += [(job.id,'updatecpwater')] except KeyError: request.session['async_tasks'] = [(job.id,'updatecpwater')] - messages.info(request,'New calculation queued. Refresh page or resubmit the date form to get the result') + messages.info(request,'New calculation queued. Page will reload automatically. You can check the status of your calculations here') powerdf = pd.DataFrame({ 'Delta':delta, @@ -4134,7 +4134,7 @@ def otwrankings_view(request,theuser=0, }) if powerdf.empty: - messages.info(request,'Your calculations are running in the background. Please reload this page.') + messages.info(request,'Your calculations are running in the background. Page will reload automatically. You can check the status of your calculations here') powerdf = powerdf[powerdf['CP']>0] powerdf.dropna(axis=0,inplace=True) @@ -4377,7 +4377,7 @@ def oterankings_view(request,theuser=0, request.session['async_tasks'] += [(job.id,'updatecp')] except KeyError: request.session['async_tasks'] = [(job.id,'updatecp')] - messages.info(request,'New calculation queued.') + messages.info(request,'New calculation queued. Page will reload automatically. You can check the status of your calculations here') powerdf = pd.DataFrame({ 'Delta':delta, @@ -4385,7 +4385,7 @@ def oterankings_view(request,theuser=0, }) if powerdf.empty: - messages.info(request,'Your calculations are running in the background. Please reload this page.') + messages.info(request,'Your calculations are running in the background. Page will reload automatically. You can check the status of your calculations here') powerdf = powerdf[powerdf['CP']>0] powerdf.dropna(axis=0,inplace=True) @@ -6878,7 +6878,7 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""): except KeyError: request.session['async_tasks'] = [(job.id,'otwsetpower')] - successmessage = 'Your calculations have been submitted. You will receive an email when they are done. You can check the status of your calculations here' + successmessage = 'Your calculations have been submitted. You will receive an email when they are done. You can check the status of your calculations here' messages.info(request,successmessage) kwargs = { 'id':int(id)}