diff --git a/rowers/forms.py b/rowers/forms.py
index f40b3439..8111b1bb 100644
--- a/rowers/forms.py
+++ b/rowers/forms.py
@@ -233,3 +233,15 @@ class IntervalUpdateForm(forms.Form):
self.fields['intervald_%s' % i].widget.attrs['style'] = 'width:76px; height: 16px;'
self.fields['type_%s' % i].widget.attrs['style'] = 'width:156px; height: 22px;'
self.fields['intervald_%s' % i].widget = forms.TimeInput(format='%H:%M:%S.%f')
+
+# This form sets options for the summary stats page
+class StatsOptionsForm(forms.Form):
+ includereststrokes = forms.BooleanField(initial=False,label='Include Rest Strokes',required=False)
+ water = forms.BooleanField(initial=False,required=False)
+ rower = forms.BooleanField(initial=True,required=False)
+ dynamic = forms.BooleanField(initial=True,required=False)
+ slides = forms.BooleanField(initial=True,required=False)
+ skierg = forms.BooleanField(initial=False,required=False)
+ paddle = forms.BooleanField(initial=False,required=False)
+ snow = forms.BooleanField(initial=False,required=False)
+ other = forms.BooleanField(initial=False,required=False)
diff --git a/rowers/templates/cumstats.html b/rowers/templates/cumstats.html
index 59b32911..564c160f 100644
--- a/rowers/templates/cumstats.html
+++ b/rowers/templates/cumstats.html
@@ -6,63 +6,63 @@
{% block content %}
-
Workout Statistics for
+
Workout Statistics
This is an experimental page which just lists a bunch of statistics for
your workouts. This page is under rapid development.
-
+
+
{% if stats %}
{% for key, value in stats.items %}
@@ -97,7 +97,7 @@
{% if cordict %}
-
Correlation table
+
Correlation Matrix
This table indicates a positive (+) or negative (-) correlation between two parameters. The strong correlations are indicated with ++ and --.
@@ -135,5 +135,5 @@
{% endif %}
-
+
{% endblock %}
diff --git a/rowers/views.py b/rowers/views.py
index e26ca8f9..1f80dda1 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -20,9 +20,13 @@ from django.conf import settings
from django.utils.datastructures import MultiValueDictKeyError
from django.utils import timezone,translation
from django.core.mail import send_mail, BadHeaderError
-from rowers.forms import EmailForm, RegistrationForm, RegistrationFormTermsOfService,RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,UpdateStreamForm
-from rowers.forms import PredictedPieceForm,DateRangeForm,DeltaDaysForm
-from rowers.forms import SummaryStringForm,IntervalUpdateForm,StrokeDataForm
+from rowers.forms import (
+ SummaryStringForm,IntervalUpdateForm,StrokeDataForm,
+ StatsOptionsForm,PredictedPieceForm,DateRangeForm,DeltaDaysForm,
+ EmailForm, RegistrationForm, RegistrationFormTermsOfService,
+ RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
+ UpdateStreamForm
+ )
from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
from rowers.models import (
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
@@ -55,7 +59,7 @@ from rowers.tasks import handle_makeplot,handle_otwsetpower,handle_sendemailtcx,
from rowers.tasks import handle_sendemail_unrecognized
from scipy.signal import savgol_filter
from django.shortcuts import render_to_response
-
+from Cookie import SimpleCookie
from shutil import copyfile
from rowingdata import rower as rrower
@@ -2616,12 +2620,20 @@ def cumstats(request,theuser=0,
deltadays=-1,
startdatestring="",
enddatestring="",
- workstrokesonly=True):
-
- workstrokesonly = True
- if request.method == 'POST' and 'workstrokesonly' in request.POST:
- workstrokesonly = request.POST['workstrokesonly']
+ options={
+ 'includereststrokes':False,
+ 'workouttypes':['rower','dynamic','slides']
+ }):
+ if 'options' in request.session:
+ options = request.session['options']
+
+ workouttypes = options['workouttypes']
+ includereststrokes = options['includereststrokes']
+ workstrokesonly = not includereststrokes
+ checktypes = ['water','rower','dynamic','slides','skierg',
+ 'paddle','snow','other']
+
if deltadays>0:
startdate = enddate-datetime.timedelta(days=int(deltadays))
@@ -2654,6 +2666,7 @@ def cumstats(request,theuser=0,
if request.method == 'POST' and "daterange" in request.POST:
form = DateRangeForm(request.POST)
deltaform = DeltaDaysForm(request.POST)
+ optionsform = StatsOptionsForm()
if form.is_valid():
startdate = form.cleaned_data['startdate']
enddate = form.cleaned_data['enddate']
@@ -2676,20 +2689,41 @@ def cumstats(request,theuser=0,
'startdate': startdate,
'enddate': enddate,
})
+ optionsform = StatsOptionsForm()
else:
form = DateRangeForm()
+ optionsform = StatsOptionsForm()
+ elif request.method == 'POST' and 'options' in request.POST:
+ optionsform = StatsOptionsForm(request.POST)
+ if optionsform.is_valid():
+ includereststrokes = optionsform.cleaned_data['includereststrokes']
+ workstrokesonly = not includereststrokes
+ workouttypes = []
+ for type in checktypes:
+ if optionsform.cleaned_data[type]:
+ workouttypes.append(type)
+ options = {
+ 'includereststrokes':includereststrokes,
+ 'workouttypes':workouttypes,
+ }
+ form = DateRangeForm()
+ deltaform = DeltaDaysForm()
+ else:
+ form = DateRangeForm()
+ deltaform = DeltaDaysForm()
else:
form = DateRangeForm(initial={
'startdate': startdate,
'enddate': enddate,
})
deltaform = DeltaDaysForm()
+ optionsform = StatsOptionsForm()
try:
r2 = Rower.objects.get(user=theuser)
allergworkouts = Workout.objects.filter(user=r2,
- workouttype__in=['rower','dynamic','slides'],
+ workouttype__in=workouttypes,
startdatetime__gte=startdate,
startdatetime__lte=enddate)
@@ -2795,7 +2829,6 @@ def cumstats(request,theuser=0,
datadf = datadf[~datadf['workoutstate'].isin(workoutstatesrest)]
except:
pass
- workstrokesonly = True
# Create stats
stats = {}
@@ -2828,20 +2861,38 @@ def cumstats(request,theuser=0,
cordict[field1] = thedict
- return render(request,
+ # set options form correctly
+ initial = {}
+ initial['includereststrokes'] = includereststrokes
+
+ for wtype in checktypes:
+ if wtype in workouttypes:
+ initial[wtype] = True
+ else:
+ initial[wtype] = False
+
+
+ optionsform = StatsOptionsForm(initial=initial)
+
+ response = render(request,
'cumstats.html',
{
'stats':stats,
- 'workstrokesonly':workstrokesonly,
+ 'options':options,
'id':theuser,
'theuser':u,
'startdate':startdate,
'enddate':enddate,
'form':form,
'deltaform':deltaform,
+ 'optionsform':optionsform,
'cordict':cordict,
})
+ request.session['options'] = options
+
+ return response
+
# Stats page
@login_required()
def workout_stats_view(request,id=0,message="",successmessage=""):