From 1ce5ba2a172e2d83fa8a03374e0287d088422af9 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 3 Apr 2018 14:59:45 +0200 Subject: [PATCH 1/5] no change --- rowers/templates/frontpage.html | 1 + 1 file changed, 1 insertion(+) diff --git a/rowers/templates/frontpage.html b/rowers/templates/frontpage.html index b01259c9..4a07ae9b 100644 --- a/rowers/templates/frontpage.html +++ b/rowers/templates/frontpage.html @@ -5,6 +5,7 @@ {% block title %}Rowsandall Rowing Data{% endblock %} {% block content %} +{% load tz %}

From 3d9ee2aa227ef7da292ce12ed659a171ca99b541 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 4 Apr 2018 17:32:18 +0200 Subject: [PATCH 2/5] added ascii utf filter to messages around comments --- rowers/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rowers/views.py b/rowers/views.py index 6d2da7c3..ef5f6f6e 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -8564,6 +8564,11 @@ def workout_comment_view(request,id=0): cd = form.cleaned_data comment = cd['comment'] comment = bleach.clean(comment) + if isinstance(comment,unicode): + comment = comment.encode('utf8') + elif isinstance(comment, str): + comment = comment.decode('utf8') + notification = cd['notification'] c = WorkoutComment(workout=w,user=request.user,comment=comment, notification=notification) From d1c4255d40c9b1712a41b4979b0be4f0ad97ac56 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 5 Apr 2018 12:33:48 +0200 Subject: [PATCH 3/5] iremoved a few extra metrics generated by rowingphysics - dont need to be on flex chart --- rowers/metrics.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rowers/metrics.py b/rowers/metrics.py index 5c22713e..94e41fbe 100644 --- a/rowers/metrics.py +++ b/rowers/metrics.py @@ -19,6 +19,14 @@ nometrics = [ ' RowingState', ' WorkoutDurationType', ' WorkoutIntervalCount', + 'ergpace', + 'deltat', + 'workoutid', + 'totalangle', + 'hr_bottom', + 'x_right', + 'equivergpower', + 'cum_dist.1' ] rowingmetrics = ( From d38e5cd813dbff5a2216333f8db3d670366f61a1 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 5 Apr 2018 15:41:47 +0200 Subject: [PATCH 4/5] box chart now uses StatsOptionsForm --- rowers/templates/user_boxplot_select.html | 21 +-- rowers/views.py | 160 ++++++++++++++++------ 2 files changed, 125 insertions(+), 56 deletions(-) diff --git a/rowers/templates/user_boxplot_select.html b/rowers/templates/user_boxplot_select.html index 9dc758b9..64960688 100644 --- a/rowers/templates/user_boxplot_select.html +++ b/rowers/templates/user_boxplot_select.html @@ -18,7 +18,7 @@ $(function() { // Get the form fields and hidden div - var modality = $("#id_modality"); + var checkbox = $("#id_water"); var hidden = $("#id_waterboattype"); @@ -28,16 +28,14 @@ hidden.hide(); - // Setup an event listener for when the state of the // checkbox changes. - modality.change(function() { + checkbox.change(function() { // Check to see if the checkbox is checked. // If it is, show the fields and populate the input. - // If not, hide the fields. - var Value = modality.val(); - if (Value=='water') { + // If not, hide the fields. + if (checkbox.is(':checked')) { // Show the hidden fields. hidden.show(); } else { @@ -55,12 +53,7 @@ // $("#hidden_field").val(""); } }); - - - }); - - - +}); @@ -119,12 +112,12 @@

- {{ modalityform.as_table }} + {{ optionsform.as_table }}
{% csrf_token %}
- +
diff --git a/rowers/views.py b/rowers/views.py index ef5f6f6e..a129d29b 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -5945,6 +5945,11 @@ def user_boxplot_select(request, successmessage='', startdate=timezone.now()-datetime.timedelta(days=30), enddate=timezone.now()+datetime.timedelta(days=1), + options={ + 'includereststrokes':False, + 'workouttypes':['rower','dynamic','slides'], + 'waterboattype':['1x','2x','2-','4x','4-','8+'] + }, userid=0): if userid == 0: @@ -5955,6 +5960,27 @@ def user_boxplot_select(request, r = getrower(user) + if 'options' in request.session: + options = request.session['options'] + + + try: + workouttypes = options['workouttypes'] + except KeyError: + workouttypes = ['rower','dynamic','slides'] + + try: + includereststrokes = options['includereststrokes'] + except KeyError: + includereststrokes = False + + + workstrokesonly = not includereststrokes + + checktypes = ['water','rower','dynamic','slides','skierg', + 'paddle','snow','other','coastal'] + waterboattype = ['1x','2x','2-','4x','4-','8+'] + if 'startdate' in request.session: startdate = iso8601.parse_date(request.session['startdate']) @@ -5962,22 +5988,23 @@ def user_boxplot_select(request, if 'enddate' in request.session: enddate = iso8601.parse_date(request.session['enddate']) + if startdatestring != "": + startdate = iso8601.parse_date(startdatestring) - if 'waterboattype' in request.session: - waterboattype = request.session['waterboattype'] - else: - waterboattype = ['1x','2x','2-','4x','4-','8+'] + if enddatestring != "": + enddate = iso8601.parse_date(enddatestring) - - if 'modalities' in request.session: - modalities = request.session['modalities'] - if len(modalities) > 1: - modality = 'all' - else: - modality = modalities[0] - else: - modalities = [m[0] for m in types.workouttypes] - modality = 'all' + if enddate < startdate: + s = enddate + enddate = startdate + startdate = s + + if 'startdate' in request.session: + startdate = iso8601.parse_date(request.session['startdate']) + + + if 'enddate' in request.session: + enddate = iso8601.parse_date(request.session['enddate']) if request.method == 'POST' and 'daterange' in request.POST: dateform = DateRangeForm(request.POST) @@ -5994,22 +6021,22 @@ def user_boxplot_select(request, 'enddate':enddate, }) - if request.method == 'POST' and 'modality' in request.POST: - modalityform = TrendFlexModalForm(request.POST) - if modalityform.is_valid(): - modality = modalityform.cleaned_data['modality'] - waterboattype = modalityform.cleaned_data['waterboattype'] - if modality == 'all': - modalities = [m[0] for m in types.workouttypes] - else: - modalities = [modality] + if request.method == 'POST' and 'optionsform' in request.POST: + optionsform = StatsOptionsForm(request.POST) + if optionsform.is_valid(): + workouttypes = [] + waterboattype = optionsform.cleaned_data['waterboattype'] + for type in checktypes: + if optionsform.cleaned_data[type]: + workouttypes.append(type) - if modality != 'water': - waterboattype = [b[0] for b in types.boattypes] + options = { + 'workouttypes':workouttypes, + 'waterboattype':waterboattype, + } + request.session['options'] = options + print options - - request.session['modalities'] = modalities - request.session['waterboattype'] = waterboattype startdate = datetime.datetime.combine(startdate,datetime.time()) enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59)) @@ -6030,10 +6057,31 @@ def user_boxplot_select(request, if b[0] not in waterboattype: negtypes.append(b[0]) - workouts = Workout.objects.filter(user=r, - startdatetime__gte=startdate, - startdatetime__lte=enddate, - workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes) + waterinclude = False + if 'water' in workouttypes: + waterinclude = True + workoutsw = Workout.objects.filter(user=r, + startdatetime__gte=startdate, + startdatetime__lte=enddate, + workouttype='water', + ).exclude(boattype__in=negtypes) + workouttypes = [w for w in workouttypes if w != 'water'] + + workoutse = Workout.objects.filter(user=r, + startdatetime__gte=startdate, + startdatetime__lte=enddate, + workouttype__in=workouttypes) + + if waterinclude: + workouts = workoutse | workoutsw + workouts = workouts.distinct().order_by("-date", "-starttime") + else: + workouts = workoutse.order_by("-date","-starttime") + + if waterinclude: + workouttypes.append('water') + + query = request.GET.get('q') if query: @@ -6049,11 +6097,18 @@ def user_boxplot_select(request, form.fields["workouts"].queryset = workouts chartform = BoxPlotChoiceForm() - modalityform = TrendFlexModalForm(initial={ - 'modality':modality, - 'waterboattype':waterboattype - }) + # set options form correctly + initial = {} + initial['waterboattype'] = waterboattype + for wtype in checktypes: + if wtype in workouttypes: + initial[wtype] = True + else: + initial[wtype] = False + + optionsform = StatsOptionsForm(initial=initial) + messages.info(request,successmessage) messages.error(request,message) @@ -6070,7 +6125,7 @@ def user_boxplot_select(request, 'theuser':user, 'form':form, 'chartform':chartform, - 'modalityform':modalityform, + 'optionsform':optionsform, 'teams':get_my_teams(request.user), }) @@ -7388,6 +7443,7 @@ def cumstats(request,theuser=0, if 'options' in request.session: options = request.session['options'] + try: workouttypes = options['workouttypes'] @@ -7497,11 +7553,31 @@ def cumstats(request,theuser=0, try: r2 = getrower(theuser) - allergworkouts = Workout.objects.filter(user=r2, - workouttype__in=workouttypes, - boattype__in=waterboattype, - startdatetime__gte=startdate, - startdatetime__lte=enddate) + waterinclude = False + if 'water' in workouttypes: + waterinclude = True + workoutsw = Workout.objects.filter(user=r2, + startdatetime__gte=startdate, + startdatetime__lte=enddate, + workouttype='water', + boattype__in='waterboattype' + ) + workouttypes = [w for w in workouttypes if w != 'water'] + + workoutse = Workout.objects.filter(user=r2, + startdatetime__gte=startdate, + startdatetime__lte=enddate, + workouttype__in=workouttypes) + + if waterinclude: + allergworkouts = workoutse | workoutsw + allergworkouts = workouts.distinct().order_by("-date", "-starttime") + else: + allergworkouts = workoutse.order_by("-date","-starttime") + + if waterinclude: + workouttypes.append('water') + except Rower.DoesNotExist: allergworkouts = [] From 30d23608ccf86976efc0311f7b5e3f42f1d76e2a Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 6 Apr 2018 10:56:48 +0200 Subject: [PATCH 5/5] in stroke extra metrics (diff, minpos, maxpos) --- rowers/dataprep.py | 5 +++++ rowers/views.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 56ce5fc4..0cdc2251 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -1663,6 +1663,11 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True): if extracols and len(ids)==1: w = Workout.objects.get(id=ids[0]) row = rdata(w.csvfilename) + try: + row.set_instroke_metrics() + except AttributeError: + pass + try: f = row.df['TimeStamp (sec)'].diff().mean() except AttributeError: diff --git a/rowers/views.py b/rowers/views.py index a129d29b..3805e49a 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -8410,6 +8410,10 @@ def workout_flexchart3_view(request,*args,**kwargs): rowdata = rdata(row.csvfilename) + try: + rowdata.set_instroke_metrics() + except AttributeError: + pass try: additionalmetrics = rowdata.get_additional_metrics() except AttributeError: