added boat type selector to stats and flexall
This commit is contained in:
@@ -275,10 +275,24 @@ class IntervalUpdateForm(forms.Form):
|
|||||||
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')
|
||||||
|
|
||||||
|
boattypes = (
|
||||||
|
('1x', '1x (single)'),
|
||||||
|
('2x', '2x (double)'),
|
||||||
|
('2-', '2- (pair)'),
|
||||||
|
('4x', '4x (quad)'),
|
||||||
|
('4-', '4- (four)'),
|
||||||
|
('8+', '8+ (eight)'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# This form sets options for the summary stats page
|
# This form sets options for the summary stats page
|
||||||
class StatsOptionsForm(forms.Form):
|
class StatsOptionsForm(forms.Form):
|
||||||
includereststrokes = forms.BooleanField(initial=False,label='Include Rest Strokes',required=False)
|
includereststrokes = forms.BooleanField(initial=False,label='Include Rest Strokes',required=False)
|
||||||
water = forms.BooleanField(initial=False,required=False)
|
water = forms.BooleanField(initial=False,required=False)
|
||||||
|
waterboattype = forms.MultipleChoiceField(choices=boattypes,
|
||||||
|
label='Water Boat Type',
|
||||||
|
widget=forms.CheckboxSelectMultiple(),
|
||||||
|
initial = ['1x','2x','2-','4x','4-','8+'])
|
||||||
rower = forms.BooleanField(initial=True,required=False)
|
rower = forms.BooleanField(initial=True,required=False)
|
||||||
dynamic = forms.BooleanField(initial=True,required=False)
|
dynamic = forms.BooleanField(initial=True,required=False)
|
||||||
slides = forms.BooleanField(initial=True,required=False)
|
slides = forms.BooleanField(initial=True,required=False)
|
||||||
|
|||||||
@@ -9,6 +9,55 @@
|
|||||||
{{ js_res | safe }}
|
{{ js_res | safe }}
|
||||||
{{ css_res| safe }}
|
{{ css_res| safe }}
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
// Get the form fields and hidden div
|
||||||
|
var checkbox = $("#id_water");
|
||||||
|
var hidden = $("#id_waterboattype");
|
||||||
|
|
||||||
|
|
||||||
|
// Hide the fields.
|
||||||
|
// Use JS to do this in case the user doesn't have JS
|
||||||
|
// enabled.
|
||||||
|
|
||||||
|
hidden.hide();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Setup an event listener for when the state of the
|
||||||
|
// checkbox changes.
|
||||||
|
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.
|
||||||
|
if (checkbox.is(':checked')) {
|
||||||
|
// Show the hidden fields.
|
||||||
|
hidden.show();
|
||||||
|
} else {
|
||||||
|
// Make sure that the hidden fields are indeed
|
||||||
|
// hidden.
|
||||||
|
hidden.hide();
|
||||||
|
|
||||||
|
// You may also want to clear the value of the
|
||||||
|
// hidden fields here. Just in case somebody
|
||||||
|
// shows the fields, enters data to them and then
|
||||||
|
// unticks the checkbox.
|
||||||
|
//
|
||||||
|
// This would do the job:
|
||||||
|
//
|
||||||
|
// $("#hidden_field").val("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/bokeh-widgets-0.12.3.min.js"></script>
|
<script type="text/javascript" src="/static/js/bokeh-widgets-0.12.3.min.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
<script async="true" type="text/javascript">
|
||||||
|
|||||||
@@ -6,14 +6,58 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
<script>
|
||||||
Bokeh.set_log_level("info");
|
$(function() {
|
||||||
</script>
|
|
||||||
|
// Get the form fields and hidden div
|
||||||
|
var checkbox = $("#id_water");
|
||||||
|
var hidden = $("#id_waterboattype");
|
||||||
|
|
||||||
{{ plotscript |safe }}
|
|
||||||
|
// Hide the fields.
|
||||||
|
// Use JS to do this in case the user doesn't have JS
|
||||||
|
// enabled.
|
||||||
|
|
||||||
<script>
|
hidden.hide();
|
||||||
|
|
||||||
|
|
||||||
|
// Setup an event listener for when the state of the
|
||||||
|
// checkbox changes.
|
||||||
|
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.
|
||||||
|
if (checkbox.is(':checked')) {
|
||||||
|
// Show the hidden fields.
|
||||||
|
hidden.show();
|
||||||
|
} else {
|
||||||
|
// Make sure that the hidden fields are indeed
|
||||||
|
// hidden.
|
||||||
|
hidden.hide();
|
||||||
|
|
||||||
|
// You may also want to clear the value of the
|
||||||
|
// hidden fields here. Just in case somebody
|
||||||
|
// shows the fields, enters data to them and then
|
||||||
|
// unticks the checkbox.
|
||||||
|
//
|
||||||
|
// This would do the job:
|
||||||
|
//
|
||||||
|
// $("#hidden_field").val("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||||
|
|
||||||
|
<script async="true" type="text/javascript">
|
||||||
|
Bokeh.set_log_level("info");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{{ plotscript |safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
// Set things up to resize the plot on a window resize. You can play with
|
// Set things up to resize the plot on a window resize. You can play with
|
||||||
// the arguments of resize_width_height() to change the plot's behavior.
|
// the arguments of resize_width_height() to change the plot's behavior.
|
||||||
var plot_resize_setup = function () {
|
var plot_resize_setup = function () {
|
||||||
|
|||||||
@@ -2097,7 +2097,8 @@ def cum_flex(request,theuser=0,
|
|||||||
enddatestring="",
|
enddatestring="",
|
||||||
options={
|
options={
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
'workouttypes':['rower','dynamic','slides']
|
'workouttypes':['rower','dynamic','slides'],
|
||||||
|
'waterboattype':['1x','2x','2-','4x','4-','8+']
|
||||||
}):
|
}):
|
||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
@@ -2108,6 +2109,7 @@ def cum_flex(request,theuser=0,
|
|||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
checktypes = ['water','rower','dynamic','slides','skierg',
|
checktypes = ['water','rower','dynamic','slides','skierg',
|
||||||
'paddle','snow','coastal','other']
|
'paddle','snow','coastal','other']
|
||||||
|
waterboattype = ['1x','2x','2-','4x','4-','8+']
|
||||||
|
|
||||||
if deltadays>0:
|
if deltadays>0:
|
||||||
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
||||||
@@ -2174,6 +2176,7 @@ def cum_flex(request,theuser=0,
|
|||||||
if optionsform.is_valid():
|
if optionsform.is_valid():
|
||||||
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
workouttypes = []
|
workouttypes = []
|
||||||
for type in checktypes:
|
for type in checktypes:
|
||||||
if optionsform.cleaned_data[type]:
|
if optionsform.cleaned_data[type]:
|
||||||
@@ -2182,6 +2185,7 @@ def cum_flex(request,theuser=0,
|
|||||||
options = {
|
options = {
|
||||||
'includereststrokes':includereststrokes,
|
'includereststrokes':includereststrokes,
|
||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
|
'waterboattype':waterboattype,
|
||||||
}
|
}
|
||||||
form = DateRangeForm(initial={
|
form = DateRangeForm(initial={
|
||||||
'startdate': startdate,
|
'startdate': startdate,
|
||||||
@@ -2205,6 +2209,7 @@ def cum_flex(request,theuser=0,
|
|||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
allworkouts = Workout.objects.filter(user=r2,
|
allworkouts = Workout.objects.filter(user=r2,
|
||||||
workouttype__in=workouttypes,
|
workouttype__in=workouttypes,
|
||||||
|
boattype__in=waterboattype,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate)
|
startdatetime__lte=enddate)
|
||||||
|
|
||||||
@@ -2242,6 +2247,8 @@ def cum_flex(request,theuser=0,
|
|||||||
initial = {}
|
initial = {}
|
||||||
initial['includereststrokes'] = includereststrokes
|
initial['includereststrokes'] = includereststrokes
|
||||||
|
|
||||||
|
initial['waterboattype'] = waterboattype
|
||||||
|
|
||||||
for wtype in checktypes:
|
for wtype in checktypes:
|
||||||
if wtype in workouttypes:
|
if wtype in workouttypes:
|
||||||
initial[wtype] = True
|
initial[wtype] = True
|
||||||
@@ -4934,7 +4941,8 @@ def cumstats(request,theuser=0,
|
|||||||
plotfield='spm',
|
plotfield='spm',
|
||||||
options={
|
options={
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
'workouttypes':['rower','dynamic','slides']
|
'workouttypes':['rower','dynamic','slides'],
|
||||||
|
'waterboattype':['1x','2x','2-','4x','4-','8+']
|
||||||
}):
|
}):
|
||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
@@ -4945,6 +4953,7 @@ def cumstats(request,theuser=0,
|
|||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
checktypes = ['water','rower','dynamic','slides','skierg',
|
checktypes = ['water','rower','dynamic','slides','skierg',
|
||||||
'paddle','snow','other','coastal']
|
'paddle','snow','other','coastal']
|
||||||
|
waterboattype = ['1x','2x','2-','4x','4-','8+']
|
||||||
|
|
||||||
if deltadays>0:
|
if deltadays>0:
|
||||||
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
||||||
@@ -5011,6 +5020,7 @@ def cumstats(request,theuser=0,
|
|||||||
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
workouttypes = []
|
workouttypes = []
|
||||||
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
for type in checktypes:
|
for type in checktypes:
|
||||||
if optionsform.cleaned_data[type]:
|
if optionsform.cleaned_data[type]:
|
||||||
workouttypes.append(type)
|
workouttypes.append(type)
|
||||||
@@ -5018,6 +5028,7 @@ def cumstats(request,theuser=0,
|
|||||||
options = {
|
options = {
|
||||||
'includereststrokes':includereststrokes,
|
'includereststrokes':includereststrokes,
|
||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
|
'waterboattype':waterboattype,
|
||||||
}
|
}
|
||||||
form = DateRangeForm()
|
form = DateRangeForm()
|
||||||
deltaform = DeltaDaysForm()
|
deltaform = DeltaDaysForm()
|
||||||
@@ -5036,6 +5047,7 @@ def cumstats(request,theuser=0,
|
|||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
allergworkouts = Workout.objects.filter(user=r2,
|
allergworkouts = Workout.objects.filter(user=r2,
|
||||||
workouttype__in=workouttypes,
|
workouttype__in=workouttypes,
|
||||||
|
boattype__in=waterboattype,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate)
|
startdatetime__lte=enddate)
|
||||||
|
|
||||||
@@ -5137,6 +5149,7 @@ def cumstats(request,theuser=0,
|
|||||||
# set options form correctly
|
# set options form correctly
|
||||||
initial = {}
|
initial = {}
|
||||||
initial['includereststrokes'] = includereststrokes
|
initial['includereststrokes'] = includereststrokes
|
||||||
|
initial['waterboattype'] = waterboattype
|
||||||
|
|
||||||
for wtype in checktypes:
|
for wtype in checktypes:
|
||||||
if wtype in workouttypes:
|
if wtype in workouttypes:
|
||||||
|
|||||||
Reference in New Issue
Block a user