Merge branch 'release/v3.65'
This commit is contained in:
@@ -1421,7 +1421,7 @@ def add_efficiency(id=0):
|
|||||||
# saves it to the stroke_data table in the database
|
# saves it to the stroke_data table in the database
|
||||||
# Takes a rowingdata object's DataFrame as input
|
# Takes a rowingdata object's DataFrame as input
|
||||||
def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
||||||
empower=True,inboard=0.88):
|
empower=True,inboard=0.88,forceunit='lbs'):
|
||||||
if rowdatadf.empty:
|
if rowdatadf.empty:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@@ -1485,8 +1485,17 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
drivespeed = 0.0*rowdatadf['TimeStamp (sec)']
|
drivespeed = 0.0*rowdatadf['TimeStamp (sec)']
|
||||||
|
|
||||||
|
|
||||||
drivespeed = drivespeed.fillna(value=0)
|
drivespeed = drivespeed.fillna(value=0)
|
||||||
driveenergy = drivelength*averageforce*lbstoN
|
|
||||||
|
try:
|
||||||
|
driveenergy = rowdatadf['driveenergy']
|
||||||
|
except KeyError:
|
||||||
|
if forceunit == 'lbs':
|
||||||
|
driveenergy = drivelength*averageforce*lbstoN
|
||||||
|
else:
|
||||||
|
drivenergy = drivelength*averageforce
|
||||||
|
|
||||||
distance = rowdatadf.ix[:,'cum_dist']
|
distance = rowdatadf.ix[:,'cum_dist']
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1918,7 +1918,6 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
yparam1 = 'None'
|
yparam1 = 'None'
|
||||||
|
|
||||||
rowdata.dropna(axis=1,how='all',inplace=True)
|
rowdata.dropna(axis=1,how='all',inplace=True)
|
||||||
rowdata.dropna(axis=0,how='any',inplace=True)
|
|
||||||
|
|
||||||
# test if we have drive energy
|
# test if we have drive energy
|
||||||
nowork = 1
|
nowork = 1
|
||||||
|
|||||||
@@ -5,15 +5,57 @@
|
|||||||
{% block title %}View Workout {% endblock %}
|
{% block title %}View Workout {% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<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");
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
|
||||||
<script async="true" type="text/javascript">
|
// Hide the fields.
|
||||||
Bokeh.set_log_level("info");
|
// Use JS to do this in case the user doesn't have JS
|
||||||
</script>
|
// enabled.
|
||||||
|
|
||||||
{{ interactiveplot |safe }}
|
hidden.hide();
|
||||||
|
|
||||||
<script>
|
|
||||||
|
// 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>
|
||||||
|
|
||||||
|
{{ interactiveplot |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 () {
|
||||||
@@ -37,9 +79,9 @@
|
|||||||
<div id="title" class="grid_12 alpha">
|
<div id="title" class="grid_12 alpha">
|
||||||
<div class="grid_10 alpha">
|
<div class="grid_10 alpha">
|
||||||
{% if theuser %}
|
{% if theuser %}
|
||||||
<h3>{{ theuser.first_name }}'s Indoor Rower Power Histogram</h3>
|
<h3>{{ theuser.first_name }}'s Stroke Analysis</h3>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h3>{{ user.first_name }}'s Indoor Rower Power Histogram</h3>
|
<h3>{{ user.first_name }}'s Stroke Analysis</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 omega">
|
<div class="grid_2 omega">
|
||||||
@@ -50,51 +92,64 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
{% for member in user|team_members %}
|
{% for member in user|team_members %}
|
||||||
<a class="button green small" href="/rowers/{{ member.id }}/histo/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}">{{ member.first_name }} {{ member.last_name }}</a>
|
<a class="button green small" href="/rowers/{{ member.id }}/flexall/{{ xparam }}/{{ yparam1 }}/{{ yparam2 }}/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}">{{ member.first_name }} {{ member.last_name }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
<div id="form" class="grid_6 alpha">
|
||||||
|
<p>Warning: Large date ranges may take a long time to load. Huge date ranges may crash your browser.</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>
|
||||||
|
</div>
|
||||||
|
<div class="grid_6 omega">
|
||||||
|
<p>Use this form to select a different date range:</p>
|
||||||
|
<p>
|
||||||
|
Select start and end date for a date range:
|
||||||
|
<div class="grid_4 alpha">
|
||||||
|
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
|
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
|
||||||
|
</div>
|
||||||
|
<div class="grid_4 alpha">
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
Or use the last {{ deltaform }} days.
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input name='datedelta' class="button green" type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="summary" class="grid_6 alpha">
|
<div id="summary" class="grid_6 suffix_6 alpha">
|
||||||
|
|
||||||
|
<p>Summary for {{ theuser.first_name }} {{ theuser.last_name }}
|
||||||
|
between {{ startdate|date }} and {{ enddate|date }}</p>
|
||||||
<p>Summary for {{ theuser.first_name }} {{ theuser.last_name }}
|
</div>
|
||||||
between {{ startdate|date }} and {{ enddate|date }}</p>
|
|
||||||
|
|
||||||
<p>Direct link for other Pro users:
|
|
||||||
<a href="/rowers/{{ id }}/histo/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}">https://rowsandall.com/rowers/{{ id }}/histo/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div id="form" class="grid_6 omega">
|
|
||||||
<p>Use this form to select a different date range:</p>
|
|
||||||
<p>
|
|
||||||
Select start and end date for a date range:
|
|
||||||
<div class="grid_4 alpha">
|
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
|
||||||
|
|
||||||
<table>
|
|
||||||
{{ form.as_table }}
|
|
||||||
</table>
|
|
||||||
{% csrf_token %}
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 omega">
|
|
||||||
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
|
|
||||||
</div>
|
|
||||||
<div class="grid_4 alpha">
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
|
||||||
Or use the last {{ deltaform }} days.
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 omega">
|
|
||||||
{% csrf_token %}
|
|
||||||
<input name='datedelta' class="button green" type="submit" value="Submit">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="graph" class="grid_12 alpha">
|
<div id="graph" class="grid_12 alpha">
|
||||||
|
|||||||
121
rowers/views.py
121
rowers/views.py
@@ -2039,7 +2039,45 @@ def rower_process_testcallback(request):
|
|||||||
|
|
||||||
# View around the Histogram of all strokes. Not implemented in UI
|
# View around the Histogram of all strokes. Not implemented in UI
|
||||||
@login_required()
|
@login_required()
|
||||||
def histo_all(request,theuser=0):
|
def histo_all(request,theuser=0,
|
||||||
|
startdate=timezone.now()-datetime.timedelta(days=10),
|
||||||
|
enddate=timezone.now()+datetime.timedelta(days=1),
|
||||||
|
deltadays=-1,
|
||||||
|
startdatestring="",
|
||||||
|
enddatestring="",
|
||||||
|
options={
|
||||||
|
'includereststrokes':False,
|
||||||
|
'workouttypes':['rower','dynamic','slides'],
|
||||||
|
'waterboattype':['1x','2x','2-','4x','4-','8+']
|
||||||
|
}):
|
||||||
|
|
||||||
|
if 'options' in request.session:
|
||||||
|
options = request.session['options']
|
||||||
|
|
||||||
|
workouttypes = options['workouttypes']
|
||||||
|
includereststrokes = options['includereststrokes']
|
||||||
|
waterboattype = options['waterboattype']
|
||||||
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
|
|
||||||
|
checktypes = ['water','rower','dynamic','slides','skierg',
|
||||||
|
'paddle','snow','coastal','other']
|
||||||
|
|
||||||
|
|
||||||
|
if deltadays>0:
|
||||||
|
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
||||||
|
|
||||||
|
if startdatestring != "":
|
||||||
|
startdate = iso8601.parse_date(startdatestring)
|
||||||
|
|
||||||
|
if enddatestring != "":
|
||||||
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
|
|
||||||
|
if enddate < startdate:
|
||||||
|
s = enddate
|
||||||
|
enddate = startdate
|
||||||
|
startdate = s
|
||||||
|
|
||||||
promember=0
|
promember=0
|
||||||
if theuser == 0:
|
if theuser == 0:
|
||||||
theuser = request.user.id
|
theuser = request.user.id
|
||||||
@@ -2192,6 +2230,7 @@ def cum_flex(request,theuser=0,
|
|||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
'waterboattype':waterboattype,
|
'waterboattype':waterboattype,
|
||||||
}
|
}
|
||||||
|
request.session['options'] = options
|
||||||
form = DateRangeForm(initial={
|
form = DateRangeForm(initial={
|
||||||
'startdate': startdate,
|
'startdate': startdate,
|
||||||
'enddate': enddate,
|
'enddate': enddate,
|
||||||
@@ -2391,7 +2430,24 @@ def histo(request,theuser=0,
|
|||||||
enddate=timezone.now(),
|
enddate=timezone.now(),
|
||||||
deltadays=-1,
|
deltadays=-1,
|
||||||
startdatestring="",
|
startdatestring="",
|
||||||
enddatestring=""):
|
enddatestring="",
|
||||||
|
options={
|
||||||
|
'includereststrokes':False,
|
||||||
|
'workouttypes':['water','rower','dynamic','slides'],
|
||||||
|
'waterboattype':['1x','2x','2-','4x','4-','8+']
|
||||||
|
}):
|
||||||
|
|
||||||
|
if 'options' in request.session:
|
||||||
|
options = request.session['options']
|
||||||
|
|
||||||
|
workouttypes = options['workouttypes']
|
||||||
|
includereststrokes = options['includereststrokes']
|
||||||
|
waterboattype = options['waterboattype']
|
||||||
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
|
|
||||||
|
checktypes = ['water','rower','dynamic','slides','skierg',
|
||||||
|
'paddle','snow','coastal','other']
|
||||||
|
|
||||||
if deltadays>0:
|
if deltadays>0:
|
||||||
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
||||||
@@ -2426,6 +2482,7 @@ def histo(request,theuser=0,
|
|||||||
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)
|
deltaform = DeltaDaysForm(request.POST)
|
||||||
|
optionsform = StatsOptionsForm()
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
startdate = form.cleaned_data['startdate']
|
startdate = form.cleaned_data['startdate']
|
||||||
enddate = form.cleaned_data['enddate']
|
enddate = form.cleaned_data['enddate']
|
||||||
@@ -2435,6 +2492,7 @@ def histo(request,theuser=0,
|
|||||||
startdate = s
|
startdate = s
|
||||||
elif request.method == 'POST' and "datedelta" in request.POST:
|
elif request.method == 'POST' and "datedelta" in request.POST:
|
||||||
deltaform = DeltaDaysForm(request.POST)
|
deltaform = DeltaDaysForm(request.POST)
|
||||||
|
optionsform = StatsOptionsForm()
|
||||||
if deltaform.is_valid():
|
if deltaform.is_valid():
|
||||||
deltadays = deltaform.cleaned_data['deltadays']
|
deltadays = deltaform.cleaned_data['deltadays']
|
||||||
if deltadays != 0 and deltadays != None:
|
if deltadays != 0 and deltadays != None:
|
||||||
@@ -2450,6 +2508,36 @@ def histo(request,theuser=0,
|
|||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
form = DateRangeForm()
|
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
|
||||||
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
|
workouttypes = []
|
||||||
|
for type in checktypes:
|
||||||
|
if optionsform.cleaned_data[type]:
|
||||||
|
workouttypes.append(type)
|
||||||
|
|
||||||
|
|
||||||
|
options = {
|
||||||
|
'includereststrokes':includereststrokes,
|
||||||
|
'workouttypes':workouttypes,
|
||||||
|
'waterboattype':waterboattype,
|
||||||
|
}
|
||||||
|
request.session['options'] = options
|
||||||
|
form = DateRangeForm(initial={
|
||||||
|
'startdate': startdate,
|
||||||
|
'enddate': enddate,
|
||||||
|
})
|
||||||
|
deltaform = DeltaDaysForm()
|
||||||
|
else:
|
||||||
|
form = DateRangeForm(initial={
|
||||||
|
'startdate': startdate,
|
||||||
|
'enddate': enddate,
|
||||||
|
})
|
||||||
|
deltaform = DeltaDaysForm()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = DateRangeForm(initial={
|
form = DateRangeForm(initial={
|
||||||
@@ -2457,11 +2545,12 @@ def histo(request,theuser=0,
|
|||||||
'enddate': enddate,
|
'enddate': enddate,
|
||||||
})
|
})
|
||||||
deltaform = DeltaDaysForm()
|
deltaform = DeltaDaysForm()
|
||||||
|
optionsform = StatsOptionsForm()
|
||||||
try:
|
try:
|
||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
allergworkouts = Workout.objects.filter(user=r2,
|
allergworkouts = Workout.objects.filter(user=r2,
|
||||||
workouttype__in=['rower','dynamic','slides'],
|
workouttype__in=workouttypes,
|
||||||
|
boattype__in=waterboattype,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate)
|
startdatetime__lte=enddate)
|
||||||
|
|
||||||
@@ -2480,8 +2569,28 @@ def histo(request,theuser=0,
|
|||||||
div = res[1]
|
div = res[1]
|
||||||
else:
|
else:
|
||||||
script = ''
|
script = ''
|
||||||
div = '<p>No erg pieces uploaded for this date range.</p>'
|
typesstring = ', '.join('{}'.format(item) for i,item in enumerate(workouttypes))
|
||||||
|
if 'water' in workouttypes:
|
||||||
|
boatsstring = 'water ('+', '.join('{}'.format(item) for i,item in enumerate(waterboattype))+')'
|
||||||
|
typesstring = typesstring.replace('water',boatsstring)
|
||||||
|
div = '<p>No pieces found for '+typesstring+' for this date range.</p>'
|
||||||
|
|
||||||
|
# set options form correctly
|
||||||
|
initial = {}
|
||||||
|
initial['includereststrokes'] = includereststrokes
|
||||||
|
|
||||||
|
initial['waterboattype'] = waterboattype
|
||||||
|
|
||||||
|
for wtype in checktypes:
|
||||||
|
if wtype in workouttypes:
|
||||||
|
initial[wtype] = True
|
||||||
|
else:
|
||||||
|
initial[wtype] = False
|
||||||
|
|
||||||
|
|
||||||
|
optionsform = StatsOptionsForm(initial=initial)
|
||||||
|
|
||||||
|
request.session['options'] = options
|
||||||
|
|
||||||
return render(request, 'histo.html',
|
return render(request, 'histo.html',
|
||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
@@ -2491,6 +2600,7 @@ def histo(request,theuser=0,
|
|||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'form':form,
|
'form':form,
|
||||||
|
'optionsform':optionsform,
|
||||||
'deltaform':deltaform,
|
'deltaform':deltaform,
|
||||||
'teams':get_my_teams(request.user),
|
'teams':get_my_teams(request.user),
|
||||||
})
|
})
|
||||||
@@ -5208,6 +5318,7 @@ def cumstats(request,theuser=0,
|
|||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
'waterboattype':waterboattype,
|
'waterboattype':waterboattype,
|
||||||
}
|
}
|
||||||
|
request.session['options'] = options
|
||||||
form = DateRangeForm()
|
form = DateRangeForm()
|
||||||
deltaform = DeltaDaysForm()
|
deltaform = DeltaDaysForm()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user