using sessions to keep workout type selected
This commit is contained in:
@@ -233,3 +233,15 @@ class IntervalUpdateForm(forms.Form):
|
|||||||
self.fields['intervald_%s' % i].widget.attrs['style'] = 'width:76px; height: 16px;'
|
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['type_%s' % i].widget.attrs['style'] = 'width:156px; height: 22px;'
|
||||||
self.fields['intervald_%s' % i].widget = forms.TimeInput(format='%H:%M:%S.%f')
|
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)
|
||||||
|
|||||||
@@ -6,63 +6,63 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
<h1>Workout Statistics for</h1>
|
<h1>Workout Statistics</h1>
|
||||||
<p>
|
<p>
|
||||||
This is an experimental page which just lists a bunch of statistics for
|
This is an experimental page which just lists a bunch of statistics for
|
||||||
your workouts. This page is under rapid development.
|
your workouts. This page is under rapid development.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="summary" class="grid_6 alpha">
|
<div class="grid_12 alpha">
|
||||||
|
<div id="summary" class="grid_6 alpha">
|
||||||
|
<p>Summary for {{ theuser.first_name }} {{ theuser.last_name }}
|
||||||
|
between {{ startdate|date }} and {{ enddate|date }}</p>
|
||||||
|
|
||||||
|
<p>Direct link for other Pro users:
|
||||||
|
<a href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}">https://rowsandall.com/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="grid_2 alpha">
|
||||||
|
<table>
|
||||||
|
{{ optionsform.as_table }}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 suffix_2 omega">
|
||||||
|
<input type="hidden" name="options" value="options">
|
||||||
|
<input class="grid_1 alpha button green small" value="Submit" type="Submit">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
<p>Summary for {{ theuser.first_name }} {{ theuser.last_name }}
|
|
||||||
between {{ startdate|date }} and {{ enddate|date }}</p>
|
|
||||||
|
|
||||||
<p>Direct link for other Pro users:
|
|
||||||
<a href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}">https://rowsandall.com/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}</a>
|
|
||||||
</p>
|
|
||||||
<div class="grid_2 omega suffix_4 tooltip">
|
|
||||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% if workstrokesonly == True %}
|
|
||||||
<input class="grid_2 alpha button blue small" type="hidden" name="workstrokesonly" value="False">
|
|
||||||
<input class="grid_2 alpha button blue small" value="Include Rest Strokes" type="Submit">
|
|
||||||
{% else %}
|
|
||||||
<input class="grid_2 alpha button blue small" type="hidden" name="workstrokesonly" value="True">
|
|
||||||
<input class="grid_2 alpha button blue small" value="Remove Rest Strokes" type="Submit">
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
<span class="tooltiptext">If your data source allows, this will show or hide strokes taken during rest intervals.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="form" class="grid_6 omega">
|
<div id="form" class="grid_6 omega">
|
||||||
<p>Use this form to select a different date range:</p>
|
<p>Use this form to select a different date range:</p>
|
||||||
<p>
|
<p>
|
||||||
Select start and end date for a date range:
|
Select start and end date for a date range:
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 alpha">
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 omega">
|
<div class="grid_2 omega">
|
||||||
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
|
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 alpha">
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
Or use the last {{ deltaform }} days.
|
Or use the last {{ deltaform }} days.
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 omega">
|
<div class="grid_2 omega">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input name='datedelta' class="button green" type="submit" value="Submit">
|
<input name='datedelta' class="button green" type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 alpha">
|
||||||
{% if stats %}
|
{% if stats %}
|
||||||
{% for key, value in stats.items %}
|
{% for key, value in stats.items %}
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="grid_8 omega">
|
<div class="grid_8 omega">
|
||||||
{% if cordict %}
|
{% if cordict %}
|
||||||
<h2> Correlation table</h2>
|
<h2> Correlation Matrix</h2>
|
||||||
<p>This table indicates a positive (+) or negative (-) correlation between two parameters. The strong correlations are indicated with ++ and --.
|
<p>This table indicates a positive (+) or negative (-) correlation between two parameters. The strong correlations are indicated with ++ and --.
|
||||||
</p>
|
</p>
|
||||||
<table width="90%" class="cortable">
|
<table width="90%" class="cortable">
|
||||||
@@ -135,5 +135,5 @@
|
|||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -20,9 +20,13 @@ from django.conf import settings
|
|||||||
from django.utils.datastructures import MultiValueDictKeyError
|
from django.utils.datastructures import MultiValueDictKeyError
|
||||||
from django.utils import timezone,translation
|
from django.utils import timezone,translation
|
||||||
from django.core.mail import send_mail, BadHeaderError
|
from django.core.mail import send_mail, BadHeaderError
|
||||||
from rowers.forms import EmailForm, RegistrationForm, RegistrationFormTermsOfService,RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,UpdateStreamForm
|
from rowers.forms import (
|
||||||
from rowers.forms import PredictedPieceForm,DateRangeForm,DeltaDaysForm
|
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 Workout, User, Rower, WorkoutForm,FavoriteChart
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
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 rowers.tasks import handle_sendemail_unrecognized
|
||||||
from scipy.signal import savgol_filter
|
from scipy.signal import savgol_filter
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
from Cookie import SimpleCookie
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
from rowingdata import rower as rrower
|
from rowingdata import rower as rrower
|
||||||
@@ -2616,11 +2620,19 @@ def cumstats(request,theuser=0,
|
|||||||
enddate=timezone.now(),
|
enddate=timezone.now(),
|
||||||
deltadays=-1,
|
deltadays=-1,
|
||||||
startdatestring="",
|
startdatestring="",
|
||||||
enddatestring="",
|
enddatestring="",
|
||||||
|
options={
|
||||||
|
'includereststrokes':False,
|
||||||
|
'workouttypes':['rower','dynamic','slides']
|
||||||
}):
|
}):
|
||||||
|
|
||||||
workstrokesonly = True
|
if 'options' in request.session:
|
||||||
if request.method == 'POST' and 'workstrokesonly' in request.POST:
|
options = request.session['options']
|
||||||
|
|
||||||
|
workouttypes = options['workouttypes']
|
||||||
|
includereststrokes = options['includereststrokes']
|
||||||
|
workstrokesonly = not includereststrokes
|
||||||
|
checktypes = ['water','rower','dynamic','slides','skierg',
|
||||||
'paddle','snow','other']
|
'paddle','snow','other']
|
||||||
|
|
||||||
if deltadays>0:
|
if deltadays>0:
|
||||||
@@ -2654,6 +2666,7 @@ def cumstats(request,theuser=0,
|
|||||||
# process form
|
# process form
|
||||||
if request.method == 'POST' and "daterange" in request.POST:
|
if request.method == 'POST' and "daterange" in request.POST:
|
||||||
form = DateRangeForm(request.POST)
|
form = DateRangeForm(request.POST)
|
||||||
|
deltaform = DeltaDaysForm(request.POST)
|
||||||
optionsform = StatsOptionsForm()
|
optionsform = StatsOptionsForm()
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
startdate = form.cleaned_data['startdate']
|
startdate = form.cleaned_data['startdate']
|
||||||
@@ -2676,20 +2689,41 @@ def cumstats(request,theuser=0,
|
|||||||
form = DateRangeForm(initial={
|
form = DateRangeForm(initial={
|
||||||
'startdate': startdate,
|
'startdate': startdate,
|
||||||
'enddate': enddate,
|
'enddate': enddate,
|
||||||
|
})
|
||||||
optionsform = StatsOptionsForm()
|
optionsform = StatsOptionsForm()
|
||||||
else:
|
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)
|
workouttypes.append(type)
|
||||||
|
|
||||||
|
options = {
|
||||||
|
'includereststrokes':includereststrokes,
|
||||||
|
'workouttypes':workouttypes,
|
||||||
|
}
|
||||||
|
form = DateRangeForm()
|
||||||
|
deltaform = DeltaDaysForm()
|
||||||
|
else:
|
||||||
|
form = DateRangeForm()
|
||||||
deltaform = DeltaDaysForm()
|
deltaform = DeltaDaysForm()
|
||||||
else:
|
else:
|
||||||
form = DateRangeForm(initial={
|
form = DateRangeForm(initial={
|
||||||
'startdate': startdate,
|
'startdate': startdate,
|
||||||
'enddate': enddate,
|
'enddate': enddate,
|
||||||
})
|
})
|
||||||
|
deltaform = DeltaDaysForm()
|
||||||
optionsform = StatsOptionsForm()
|
optionsform = StatsOptionsForm()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r2 = Rower.objects.get(user=theuser)
|
r2 = Rower.objects.get(user=theuser)
|
||||||
allergworkouts = Workout.objects.filter(user=r2,
|
allergworkouts = Workout.objects.filter(user=r2,
|
||||||
workouttype__in=workouttypes,
|
workouttype__in=workouttypes,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate)
|
startdatetime__lte=enddate)
|
||||||
@@ -2795,7 +2829,6 @@ def cumstats(request,theuser=0,
|
|||||||
try:
|
try:
|
||||||
datadf = datadf[~datadf['workoutstate'].isin(workoutstatesrest)]
|
datadf = datadf[~datadf['workoutstate'].isin(workoutstatesrest)]
|
||||||
except:
|
except:
|
||||||
pass
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create stats
|
# Create stats
|
||||||
@@ -2828,20 +2861,38 @@ def cumstats(request,theuser=0,
|
|||||||
thedict[field2] = 0
|
thedict[field2] = 0
|
||||||
|
|
||||||
cordict[field1] = thedict
|
cordict[field1] = thedict
|
||||||
|
|
||||||
|
# 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,
|
response = render(request,
|
||||||
'cumstats.html',
|
'cumstats.html',
|
||||||
{
|
{
|
||||||
'stats':stats,
|
'stats':stats,
|
||||||
'options':options,
|
'options':options,
|
||||||
'id':theuser,
|
'id':theuser,
|
||||||
'theuser':u,
|
'theuser':u,
|
||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'form':form,
|
'form':form,
|
||||||
|
'deltaform':deltaform,
|
||||||
'optionsform':optionsform,
|
'optionsform':optionsform,
|
||||||
'cordict':cordict,
|
'cordict':cordict,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
request.session['options'] = options
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
# Stats page
|
# Stats page
|
||||||
@login_required()
|
@login_required()
|
||||||
|
|||||||
Reference in New Issue
Block a user