Merge branch 'release/v4.9'
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
<div id="id_script">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Set things up to resize the plot on a window resize. You can play with
|
||||
@@ -37,7 +38,7 @@
|
||||
<div class="grid_12 alpha">
|
||||
<h1>Box Chart</h1>
|
||||
<div id="workouts" class="grid_8 alpha">
|
||||
<div id="theplot" class="grid_8 alpha flexplot">
|
||||
<div id="id_chart" class="grid_8 alpha flexplot">
|
||||
{{ the_div|safe }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -67,4 +68,27 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(function($) {
|
||||
console.log('loading script');
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/user-boxplot-data', function(json) {
|
||||
var counter=0;
|
||||
var script = json.script;
|
||||
var div = json.div;
|
||||
$("#id_sitready").remove();
|
||||
$("#id_chart").append(div);
|
||||
console.log(div);
|
||||
$("#id_script").append("<script>"+script+"</s"+"cript>");
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -6,8 +6,23 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ js_res | safe }}
|
||||
{{ css_res| safe }}
|
||||
|
||||
<div id="id_css_res">
|
||||
<link rel="stylesheet" href="/static/css/bokeh-0.12.3.min.css" type="text/css" />
|
||||
<link rel="stylesheet" href="/static/css/bokeh-widgets-0.12.3.min.css" type="text/css" />
|
||||
</div>
|
||||
<div id="id_js_res">
|
||||
<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 async="true" type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
@@ -58,13 +73,10 @@
|
||||
|
||||
</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 async="true" type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
<div id="id_script">
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||
@@ -74,11 +86,7 @@
|
||||
|
||||
<div id="title" class="grid_12 alpha">
|
||||
<div class="grid_10 alpha">
|
||||
{% if theuser %}
|
||||
<h3>{{ theuser.first_name }}'s Stroke Analysis</h3>
|
||||
{% else %}
|
||||
<h3>{{ user.first_name }}'s Stroke Analysis</h3>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
{% if user.is_authenticated and user|is_manager %}
|
||||
@@ -99,7 +107,6 @@
|
||||
|
||||
<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">
|
||||
@@ -229,10 +236,33 @@
|
||||
|
||||
|
||||
|
||||
<div id="graph" class="grid_12 alpha">
|
||||
<div id="id_chart" class="grid_12 alpha">
|
||||
|
||||
{{ the_div|safe }}
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(function($) {
|
||||
console.log('loading script');
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/flexalldata', function(json) {
|
||||
var counter=0;
|
||||
var script = json.script;
|
||||
var div = json.div;
|
||||
$("#id_sitready").remove();
|
||||
$("#id_chart").append(div);
|
||||
console.log(div);
|
||||
$("#id_script").append("<script>"+script+"</s"+"cript>");
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -15,12 +15,28 @@
|
||||
$(document).ready(function() {
|
||||
$('#id_file').on('change', function(evt) {
|
||||
var f = this.files[0];
|
||||
var istcx = false;
|
||||
var isgzip = false;
|
||||
var size1 = 10485760;
|
||||
var size2 = 1048576;
|
||||
if ((/\.(tcx|TCX)/i).test(f.name)) {
|
||||
istcx = true;
|
||||
console.log('tcx');
|
||||
if ((/\.(gz|GZ)/i).test(f.name)) {
|
||||
isgzip = true;
|
||||
console.log('gzip');
|
||||
size1 /= 5;
|
||||
size2 /= 5;
|
||||
}
|
||||
}
|
||||
console.log(f);
|
||||
if (f.size > 4194304) {
|
||||
alert("File Size must be smaller than 4 MB");
|
||||
console.log(size1)
|
||||
console.log(size2)
|
||||
if (f.size > size1) {
|
||||
alert("File Size must be smaller than 10 MB");
|
||||
this.value = null;
|
||||
}
|
||||
if (f.size > 1048576) {
|
||||
if (f.size > size2) {
|
||||
$('#id_offline').val('True');
|
||||
$('#id_offline').prop('checked','True');
|
||||
console.log("Set offline to True");
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
{% if charts %}
|
||||
|
||||
|
||||
<h2>Flex Charts</h2>
|
||||
<p>Click on the thumbnails to view the full chart.</p>
|
||||
{% for chart in charts %}
|
||||
<div class="grid_3 alpha">
|
||||
<big>{{ forloop.counter }}</big>
|
||||
<div class="grid_3 tooltip">
|
||||
<a href="/rowers/workout/{{ workout.id }}/flexchart?favoritechart={{ forloop.counter |add:"-1" }}">
|
||||
{{ chart.div | safe }}
|
||||
</a>
|
||||
{% if rower.showfavoritechartnotes %}
|
||||
<span class="tooltiptext">{{ chart.notes }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div id="id_thumbscripts">
|
||||
|
||||
</div>
|
||||
<div id="id_thumbs">
|
||||
{{ charts | safe }}
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
<div id="id_script">
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Set things up to resize the plot on a window resize. You can play with
|
||||
@@ -37,7 +39,7 @@
|
||||
<div class="grid_12 alpha">
|
||||
<h1>Multi Flex Chart</h1>
|
||||
<div id="workouts" class="grid_8 alpha">
|
||||
<div id="theplot" class="grid_8 alpha flexplot">
|
||||
<div id="id_chart" class="grid_8 alpha flexplot">
|
||||
{{ the_div|safe }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -67,4 +69,27 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(function($) {
|
||||
console.log('loading script');
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/user-multiflex-data', function(json) {
|
||||
var counter=0;
|
||||
var script = json.script;
|
||||
var div = json.div;
|
||||
$("#id_sitready").remove();
|
||||
$("#id_chart").append(div);
|
||||
console.log(div);
|
||||
$("#id_script").append("<script>"+script+"</s"+"cript>");
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -25,6 +25,46 @@
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
<script>
|
||||
$(function($) {
|
||||
console.log('loading script');
|
||||
var workoutid = {{ workout.id }};
|
||||
var shownotes = true;
|
||||
if("{{ rower.showfavoritechartnotes }}" == "False") {
|
||||
shownotes = false;
|
||||
}
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/workout/{{ workout.id }}/get-thumbnails', function(json) {
|
||||
var counter=0;
|
||||
$("#id_sitready").remove();
|
||||
$("#id_thumbs").append(
|
||||
"<p>Click on the thumbnails to view the full chart.</p>");
|
||||
$.each(json, function(index, element) {
|
||||
console.log('adding thumbnail');
|
||||
var counter2 = counter+1;
|
||||
if (shownotes) {
|
||||
$("#id_thumbs").append(
|
||||
"<div class=\"grid_3 alpha\">"+
|
||||
"<big>"+counter2+"</big>"+
|
||||
"<div class=\"grid_3 tooltip\">"+
|
||||
"<a href=\"/rowers/workout/"+workoutid+"/flexchart?favoritechart="+counter+"\">"+element.div+"</a>"+
|
||||
"<span class=\"tooltiptext\">"+element.notes+"</span>"+
|
||||
"</div></div>");
|
||||
} else {
|
||||
$("#id_thumbs").append(
|
||||
"<div class=\"grid_3 alpha\">"+
|
||||
"<big>"+counter2+"</big>"+
|
||||
"<div class=\"grid_3 tooltip\">"+
|
||||
"<a href=\"/rowers/workout/"+workoutid+"/flexchart?favoritechart="+counter+"\">"+element.div+"</a>"+
|
||||
"</div></div>");
|
||||
|
||||
}
|
||||
$("#id_thumbscripts").append(element.script);
|
||||
counter += 1;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
14
rowers/templates/workflow_snippet.html
Normal file
14
rowers/templates/workflow_snippet.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{% for chart in charts %}
|
||||
<div class="grid_3 alpha">
|
||||
<big>{{ forloop.counter }}</big>
|
||||
<div class="grid_3 tooltip">
|
||||
<a href="/rowers/workout/{{ workout.id }}/flexchart?favoritechart={{ forloop.counter |add:"-1" }}">
|
||||
{{ chart.div | safe }}
|
||||
</a>
|
||||
{% if rower.showfavoritechartnotes %}
|
||||
<span class="tooltiptext">{{ chart.notes }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -169,6 +169,8 @@ urlpatterns = [
|
||||
url(r'^flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)$',views.cum_flex),
|
||||
url(r'^flexall/$',views.cum_flex),
|
||||
|
||||
url(r'^flexalldata/$',views.cum_flex_data),
|
||||
|
||||
url(r'^histo/u/(?P<theuser>\d+)$',views.histo),
|
||||
url(r'^flexall/u/(?P<theuser>\d+)$',views.cum_flex),
|
||||
url(r'^(?P<theuser>\d+)/histo/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.histo),
|
||||
@@ -190,6 +192,7 @@ urlpatterns = [
|
||||
url(r'^graph/(?P<id>\d+)/deleteconfirm$',views.graph_delete_confirm_view),
|
||||
url(r'^graph/(?P<id>\d+)/delete$',views.graph_delete_view),
|
||||
url(r'^workout/(?P<id>\d+)/get-thumbnails$',views.get_thumbnails),
|
||||
url(r'^workout/(?P<id>\d+)/get-testscript$',views.get_testscript),
|
||||
url(r'^workout/upload/team/$',views.team_workout_upload_view),
|
||||
url(r'^workout/upload/$',views.workout_upload_view,name='workout_upload_view'),
|
||||
url(r'^workout/(?P<id>\d+)/histo$',views.workout_histo_view),
|
||||
@@ -289,9 +292,11 @@ urlpatterns = [
|
||||
url(r'^user-boxplot/(?P<userid>\d+)$',views.boxplot_view),
|
||||
url(r'^user-boxplot/$',views.boxplot_view),
|
||||
url(r'^user-boxplot$',views.boxplot_view),
|
||||
url(r'^user-boxplot-data$',views.boxplot_view_data),
|
||||
url(r'^user-multiflex/(?P<userid>\d+)$',views.multiflex_view),
|
||||
url(r'^user-multiflex/$',views.multiflex_view),
|
||||
url(r'^user-multiflex$',views.multiflex_view),
|
||||
url(r'^user-multiflex-data$',views.multiflex_data),
|
||||
url(r'^me/teams/$',views.rower_teams_view),
|
||||
url(r'^me/calcdps/$',views.rower_calcdps_view),
|
||||
url(r'^me/exportsettings/$',views.rower_exportsettings_view),
|
||||
|
||||
@@ -57,6 +57,32 @@ defaultleft = [
|
||||
'panel_staticchart.html',
|
||||
]
|
||||
|
||||
coxes_calls = [
|
||||
'Sit Ready!',
|
||||
"Let's relax the shoulders, and give me a power ten to the finish!",
|
||||
"Almost there. Give me ten strokes on the legs!",
|
||||
"Let it run!",
|
||||
]
|
||||
|
||||
info_calls = [
|
||||
"Please give us a minute to count all those strokes, you've been working hard!",
|
||||
"Please give us a minute to count all your strokes."
|
||||
]
|
||||
|
||||
import random
|
||||
|
||||
def get_call():
|
||||
call1 = random.choice(coxes_calls)
|
||||
call2 = random.choice(info_calls)
|
||||
|
||||
call = """<div id="id_sitready" class="successmessage">
|
||||
<p>
|
||||
%s (%s)
|
||||
</p>
|
||||
</div>
|
||||
""" % (call1, call2)
|
||||
|
||||
return call
|
||||
|
||||
def absolute(request):
|
||||
urls = {
|
||||
|
||||
660
rowers/views.py
660
rowers/views.py
@@ -515,6 +515,33 @@ def get_thumbnails(request,id):
|
||||
|
||||
return JSONResponse(charts)
|
||||
|
||||
@login_required()
|
||||
def get_testscript(request,id):
|
||||
try:
|
||||
row = Workout.objects.get(id=id)
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("Workout doesn't exist")
|
||||
if (checkworkoutuser(request.user,row)==False):
|
||||
raise Http404("You are not allowed to edit this workout")
|
||||
|
||||
r = getrower(request.user)
|
||||
|
||||
object = {
|
||||
"script":"""
|
||||
<div id="id_script">
|
||||
<script>alert("hi")</script>
|
||||
</div>
|
||||
""",
|
||||
"div":"""
|
||||
<div id="id_div">
|
||||
Hoi
|
||||
</div>
|
||||
"""
|
||||
}
|
||||
|
||||
|
||||
return JSONResponse([object,object])
|
||||
|
||||
@login_required()
|
||||
def session_jobs_view(request):
|
||||
taskstatus = get_stored_tasks_status(request)
|
||||
@@ -673,7 +700,7 @@ def splitstdata(lijst):
|
||||
|
||||
from utils import (
|
||||
geo_distance,serialize_list,deserialize_list,uniqify,
|
||||
str2bool,range_to_color_hex,absolute,myqueue
|
||||
str2bool,range_to_color_hex,absolute,myqueue,get_call
|
||||
)
|
||||
|
||||
import datautils
|
||||
@@ -2499,6 +2526,99 @@ def histo_all(request,theuser=0,
|
||||
})
|
||||
|
||||
# The Flex plot for a large selection of workouts
|
||||
@login_required()
|
||||
def cum_flex_data(
|
||||
request,
|
||||
options={
|
||||
'includereststrokes':False,
|
||||
'workouttypes':['rower','dynamic','slides'],
|
||||
'waterboattype':['1x','2x','2-','4x','4-','8+'],
|
||||
'theuser':0,
|
||||
'xparam':'spm',
|
||||
'yparam1':'power',
|
||||
'yparam2':'None',
|
||||
'enddatestring':'',
|
||||
'startdatestring':'',
|
||||
'deltadays':-1,
|
||||
}):
|
||||
|
||||
if 'options' in request.session:
|
||||
options = request.session['options']
|
||||
|
||||
workouttypes = options['workouttypes']
|
||||
includereststrokes = options['includereststrokes']
|
||||
waterboattype = options['waterboattype']
|
||||
workstrokesonly = not includereststrokes
|
||||
theuser = options['theuser']
|
||||
xparam = options['xparam']
|
||||
yparam1 = options['yparam1']
|
||||
yparam2 = options['yparam2']
|
||||
startdatestring = options['startdatestring']
|
||||
enddatestring = options['enddatestring']
|
||||
deltadays = options['deltadays']
|
||||
|
||||
|
||||
try:
|
||||
startdate = iso8601.parse_date(startdatestring)
|
||||
except ParseError:
|
||||
startdate = timezone.now()-datetime.timedelta(days=7)
|
||||
|
||||
try:
|
||||
enddate = iso8601.parse_date(enddatestring)
|
||||
except ParseError:
|
||||
enddate = timezone.now()
|
||||
|
||||
if deltadays>0:
|
||||
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
||||
|
||||
|
||||
if enddate < startdate:
|
||||
s = enddate
|
||||
enddate = startdate
|
||||
startdate = s
|
||||
|
||||
promember=0
|
||||
if theuser == 0:
|
||||
theuser = request.user.id
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
r = getrower(request.user)
|
||||
result = request.user.is_authenticated() and ispromember(request.user)
|
||||
if result:
|
||||
promember=1
|
||||
|
||||
r2 = getrower(theuser)
|
||||
allworkouts = Workout.objects.filter(user=r2,
|
||||
workouttype__in=workouttypes,
|
||||
boattype__in=waterboattype,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate)
|
||||
|
||||
if allworkouts:
|
||||
res = interactive_cum_flex_chart2(allworkouts,xparam=xparam,
|
||||
yparam1=yparam1,
|
||||
yparam2=yparam2,
|
||||
promember=promember,
|
||||
workstrokesonly=workstrokesonly)
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
else:
|
||||
script = ''
|
||||
div = '<p>No erg pieces uploaded for this date range.</p>'
|
||||
|
||||
scripta = script.split('\n')[2:-1]
|
||||
script = ''.join(scripta)
|
||||
|
||||
data = {
|
||||
"script":script,
|
||||
"div":div,
|
||||
}
|
||||
|
||||
return JSONResponse(data)
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required()
|
||||
def cum_flex(request,theuser=0,
|
||||
xparam='spm',
|
||||
@@ -2624,38 +2744,11 @@ def cum_flex(request,theuser=0,
|
||||
})
|
||||
deltaform = DeltaDaysForm()
|
||||
optionsform = StatsOptionsForm()
|
||||
try:
|
||||
r2 = getrower(theuser)
|
||||
allworkouts = Workout.objects.filter(user=r2,
|
||||
workouttype__in=workouttypes,
|
||||
boattype__in=waterboattype,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate)
|
||||
|
||||
except Rower.DoesNotExist:
|
||||
allworkouts = []
|
||||
r2=0
|
||||
|
||||
try:
|
||||
u = User.objects.get(id=theuser)
|
||||
except User.DoesNotExist:
|
||||
u = ''
|
||||
|
||||
if allworkouts:
|
||||
res = interactive_cum_flex_chart2(allworkouts,xparam=xparam,
|
||||
yparam1=yparam1,
|
||||
yparam2=yparam2,
|
||||
promember=promember,
|
||||
workstrokesonly=workstrokesonly)
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
js_resources = res[2]
|
||||
css_resources = res[3]
|
||||
else:
|
||||
script = ''
|
||||
div = '<p>No erg pieces uploaded for this date range.</p>'
|
||||
js_resources = ''
|
||||
css_resources = ''
|
||||
script = ''
|
||||
div = get_call()
|
||||
js_resources = ''
|
||||
css_resources = ''
|
||||
|
||||
axchoicesbasic = {ax[0]:ax[1] for ax in axes if ax[4]=='basic'}
|
||||
axchoicespro = {ax[0]:ax[1] for ax in axes if ax[4]=='pro'}
|
||||
@@ -2675,8 +2768,26 @@ def cum_flex(request,theuser=0,
|
||||
initial[wtype] = False
|
||||
|
||||
|
||||
try:
|
||||
u = User.objects.get(id=theuser)
|
||||
except User.DoesNotExist:
|
||||
u = ''
|
||||
|
||||
optionsform = StatsOptionsForm(initial=initial)
|
||||
|
||||
|
||||
options['includereststrokes'] = includereststrokes
|
||||
options['workouttypes'] =workouttypes
|
||||
options['waterboattype'] =waterboattype
|
||||
options['theuser'] =theuser
|
||||
options['xparam'] =xparam
|
||||
options['yparam1'] =yparam1
|
||||
options['yparam2'] =yparam2
|
||||
options['startdatestring'] = startdatestring
|
||||
options['enddatestring'] =enddatestring
|
||||
options['deltadays'] =deltadays
|
||||
|
||||
|
||||
request.session['options'] = options
|
||||
|
||||
return render(request, 'cum_flex.html',
|
||||
@@ -2701,6 +2812,7 @@ def cum_flex(request,theuser=0,
|
||||
'noylist':noylist,
|
||||
})
|
||||
|
||||
|
||||
# Show the EMpower Oarlock generated Stroke Profile
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
||||
@@ -4330,10 +4442,22 @@ def user_multiflex_select(request,
|
||||
})
|
||||
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def multiflex_view(request,userid=0,
|
||||
def multiflex_data(request,userid=0,
|
||||
options={
|
||||
'includereststrokes':False,
|
||||
'ploterrorbars':False,
|
||||
'userid':0,
|
||||
'palette': 'monochrome_blue',
|
||||
'groupby': 'spm',
|
||||
'binsize': 1,
|
||||
'xparam': 'hr',
|
||||
'yparam': 'pace',
|
||||
'spmmin': 15,
|
||||
'spmmax': 55,
|
||||
'workmin': 400,
|
||||
'workmax': 1500,
|
||||
'ids': [],
|
||||
'ploterrorbars':False,
|
||||
}):
|
||||
|
||||
if 'options' in request.session:
|
||||
@@ -4358,90 +4482,23 @@ def multiflex_view(request,userid=0,
|
||||
|
||||
if userid==0:
|
||||
userid = request.user.id
|
||||
|
||||
palette = options['palette']
|
||||
groupby = options['groupby']
|
||||
binsize = options['binsize']
|
||||
xparam = options['xparam']
|
||||
yparam = options['yparam']
|
||||
spmmin = options['spmmin']
|
||||
spmmax = options['spmmax']
|
||||
workmin = options['workmin']
|
||||
workmax = options['workmax']
|
||||
ids = options['ids']
|
||||
|
||||
workouts = [Workout.objects.get(id=id) for id in ids]
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
}
|
||||
|
||||
if request.method == 'POST' and 'workouts' in request.POST:
|
||||
form = WorkoutMultipleCompareForm(request.POST)
|
||||
chartform = MultiFlexChoiceForm(request.POST)
|
||||
if form.is_valid() and chartform.is_valid():
|
||||
cd = form.cleaned_data
|
||||
workouts = cd['workouts']
|
||||
xparam = chartform.cleaned_data['xparam']
|
||||
yparam = chartform.cleaned_data['yparam']
|
||||
includereststrokes = chartform.cleaned_data['includereststrokes']
|
||||
ploterrorbars = chartform.cleaned_data['ploterrorbars']
|
||||
request.session['ploterrorbars'] = ploterrorbars
|
||||
request.session['includereststrokes'] = includereststrokes
|
||||
workstrokesonly = not includereststrokes
|
||||
palette = chartform.cleaned_data['palette']
|
||||
request.session['palette'] = palette
|
||||
|
||||
groupby = chartform.cleaned_data['groupby']
|
||||
binsize = chartform.cleaned_data['binsize']
|
||||
if binsize <= 0:
|
||||
binsize = 1
|
||||
if groupby == 'pace':
|
||||
binsize *= 1000
|
||||
|
||||
spmmin = chartform.cleaned_data['spmmin']
|
||||
spmmax = chartform.cleaned_data['spmmax']
|
||||
workmin = chartform.cleaned_data['workmin']
|
||||
workmax = chartform.cleaned_data['workmax']
|
||||
|
||||
ids = [int(w.id) for w in workouts]
|
||||
request.session['ids'] = ids
|
||||
|
||||
else:
|
||||
return HttpResponse("Form is not valid")
|
||||
elif request.method == 'POST' and 'ids' in request.session:
|
||||
chartform = MultiFlexChoiceForm(request.POST)
|
||||
if chartform.is_valid():
|
||||
xparam = chartform.cleaned_data['xparam']
|
||||
yparam = chartform.cleaned_data['yparam']
|
||||
includereststrokes = chartform.cleaned_data['includereststrokes']
|
||||
ploterrorbars = chartform.cleaned_data['ploterrorbars']
|
||||
request.session['ploterrorbars'] = ploterrorbars
|
||||
request.session['includereststrokes'] = includereststrokes
|
||||
workstrokesonly = not includereststrokes
|
||||
palette = chartform.cleaned_data['palette']
|
||||
request.session['palette'] = palette
|
||||
|
||||
groupby = chartform.cleaned_data['groupby']
|
||||
binsize = chartform.cleaned_data['binsize']
|
||||
if binsize <= 0:
|
||||
binsize = 1
|
||||
if groupby == 'pace':
|
||||
binsize *= 1000.
|
||||
|
||||
spmmin = chartform.cleaned_data['spmmin']
|
||||
spmmax = chartform.cleaned_data['spmmax']
|
||||
workmin = chartform.cleaned_data['workmin']
|
||||
workmax = chartform.cleaned_data['workmax']
|
||||
|
||||
ids = request.session['ids']
|
||||
request.session['ids'] = ids
|
||||
workouts = dataprep.get_workouts(ids,userid)
|
||||
if not workouts:
|
||||
message = 'Error: Workouts in session storage do not belong to this user.'
|
||||
messages.error(request,message)
|
||||
url = reverse(user_multiflex_select,
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
}
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# workouts = [Workout.objects.get(id=id) for id in ids]
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
}
|
||||
|
||||
else:
|
||||
return HttpResponse("invalid form")
|
||||
else:
|
||||
url = reverse(user_multiflex_select)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
fieldlist,fielddict = dataprep.getstatsfields()
|
||||
fieldlist = [xparam,yparam,groupby,
|
||||
'workoutid','spm','driveenergy',
|
||||
@@ -4597,10 +4654,145 @@ def multiflex_view(request,userid=0,
|
||||
binsize=binsize,
|
||||
colorlegend=colorlegend)
|
||||
|
||||
scripta= script.split('\n')[2:-1]
|
||||
script = ''.join(scripta)
|
||||
|
||||
|
||||
return JSONResponse({
|
||||
"script":script,
|
||||
"div":div,
|
||||
})
|
||||
|
||||
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def multiflex_view(request,userid=0,
|
||||
options={
|
||||
'includereststrokes':False,
|
||||
'ploterrorbars':False,
|
||||
}):
|
||||
|
||||
if 'options' in request.session:
|
||||
options = request.session['options']
|
||||
|
||||
try:
|
||||
includereststrokes = options['includereststrokes']
|
||||
except KeyError:
|
||||
includereststrokes = False
|
||||
|
||||
try:
|
||||
ploterrorbars = options['ploterrorbars']
|
||||
except KeyError:
|
||||
ploterrorbars = False
|
||||
|
||||
try:
|
||||
palette = request.session['palette']
|
||||
except KeyError:
|
||||
palette = 'monochrome_blue'
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
if userid==0:
|
||||
userid = request.user.id
|
||||
|
||||
if request.method == 'POST' and 'workouts' in request.POST:
|
||||
form = WorkoutMultipleCompareForm(request.POST)
|
||||
chartform = MultiFlexChoiceForm(request.POST)
|
||||
if form.is_valid() and chartform.is_valid():
|
||||
cd = form.cleaned_data
|
||||
workouts = cd['workouts']
|
||||
xparam = chartform.cleaned_data['xparam']
|
||||
yparam = chartform.cleaned_data['yparam']
|
||||
includereststrokes = chartform.cleaned_data['includereststrokes']
|
||||
ploterrorbars = chartform.cleaned_data['ploterrorbars']
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
palette = chartform.cleaned_data['palette']
|
||||
|
||||
groupby = chartform.cleaned_data['groupby']
|
||||
binsize = chartform.cleaned_data['binsize']
|
||||
if binsize <= 0:
|
||||
binsize = 1
|
||||
if groupby == 'pace':
|
||||
binsize *= 1000
|
||||
|
||||
spmmin = chartform.cleaned_data['spmmin']
|
||||
spmmax = chartform.cleaned_data['spmmax']
|
||||
workmin = chartform.cleaned_data['workmin']
|
||||
workmax = chartform.cleaned_data['workmax']
|
||||
|
||||
ids = [int(w.id) for w in workouts]
|
||||
request.session['ids'] = ids
|
||||
|
||||
else:
|
||||
return HttpResponse("Form is not valid")
|
||||
elif request.method == 'POST' and 'ids' in request.session:
|
||||
chartform = MultiFlexChoiceForm(request.POST)
|
||||
if chartform.is_valid():
|
||||
xparam = chartform.cleaned_data['xparam']
|
||||
yparam = chartform.cleaned_data['yparam']
|
||||
includereststrokes = chartform.cleaned_data['includereststrokes']
|
||||
ploterrorbars = chartform.cleaned_data['ploterrorbars']
|
||||
request.session['ploterrorbars'] = ploterrorbars
|
||||
request.session['includereststrokes'] = includereststrokes
|
||||
workstrokesonly = not includereststrokes
|
||||
palette = chartform.cleaned_data['palette']
|
||||
|
||||
groupby = chartform.cleaned_data['groupby']
|
||||
binsize = chartform.cleaned_data['binsize']
|
||||
if binsize <= 0:
|
||||
binsize = 1
|
||||
if groupby == 'pace':
|
||||
binsize *= 1000.
|
||||
|
||||
spmmin = chartform.cleaned_data['spmmin']
|
||||
spmmax = chartform.cleaned_data['spmmax']
|
||||
workmin = chartform.cleaned_data['workmin']
|
||||
workmax = chartform.cleaned_data['workmax']
|
||||
|
||||
ids = request.session['ids']
|
||||
request.session['ids'] = ids
|
||||
workouts = dataprep.get_workouts(ids,userid)
|
||||
if not workouts:
|
||||
message = 'Error: Workouts in session storage do not belong to this user.'
|
||||
messages.error(request,message)
|
||||
url = reverse(user_multiflex_select,
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
}
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# workouts = [Workout.objects.get(id=id) for id in ids]
|
||||
|
||||
|
||||
else:
|
||||
return HttpResponse("invalid form")
|
||||
else:
|
||||
url = reverse(user_multiflex_select)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
div = get_call()
|
||||
|
||||
options['includereststrokes'] = includereststrokes
|
||||
options['ploterrorbars'] = ploterrorbars
|
||||
options['userid'] = userid
|
||||
options['palette'] = palette
|
||||
options['groupby'] = groupby
|
||||
options['binsize'] = binsize
|
||||
options['xparam'] = xparam
|
||||
options['yparam'] = yparam
|
||||
options['spmmin'] = spmmin
|
||||
options['spmmax'] = spmmax
|
||||
options['workmin'] = workmin
|
||||
options['workmax'] = workmax
|
||||
options['ids'] = ids
|
||||
|
||||
|
||||
request.session['options'] = options
|
||||
|
||||
|
||||
return render(request,'multiflex.html',
|
||||
{'interactiveplot':script,
|
||||
{'interactiveplot':'',
|
||||
'the_div':div,
|
||||
'chartform':chartform,
|
||||
'userid':userid,
|
||||
@@ -4746,6 +4938,93 @@ def user_boxplot_select(request,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def boxplot_view_data(request,userid=0,
|
||||
options={
|
||||
'includereststrokes':False,
|
||||
'spmmin':15,
|
||||
'spmmax':55,
|
||||
'workmin':0,
|
||||
'workmax':1500,
|
||||
'ids':[],
|
||||
'userid':0,
|
||||
'plotfield':'spm',
|
||||
}):
|
||||
|
||||
if 'options' in request.session:
|
||||
options = request.session['options']
|
||||
|
||||
includereststrokes = options['includereststrokes']
|
||||
spmmin = options['spmmin']
|
||||
spmmax = options['spmmax']
|
||||
workmin = options['workmin']
|
||||
workmax = options['workmax']
|
||||
ids = options['ids']
|
||||
userid = options['userid']
|
||||
plotfield = options['plotfield']
|
||||
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
if userid==0:
|
||||
userid = request.user.id
|
||||
|
||||
workouts = [Workout.objects.get(id=id) for id in ids]
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
}
|
||||
|
||||
|
||||
datemapping = {
|
||||
w.id:w.date for w in workouts
|
||||
}
|
||||
|
||||
|
||||
|
||||
fieldlist,fielddict = dataprep.getstatsfields()
|
||||
fieldlist = [plotfield,'workoutid','spm','driveenergy',
|
||||
'workoutstate']
|
||||
|
||||
# prepare data frame
|
||||
datadf = dataprep.read_cols_df_sql(ids,fieldlist)
|
||||
|
||||
datadf = dataprep.clean_df_stats(datadf,workstrokesonly=workstrokesonly)
|
||||
|
||||
datadf = dataprep.filter_df(datadf,'spm',spmmin,
|
||||
largerthan=True)
|
||||
datadf = dataprep.filter_df(datadf,'spm',spmmax,
|
||||
largerthan=False)
|
||||
datadf = dataprep.filter_df(datadf,'driveenergy',workmin,
|
||||
largerthan=True)
|
||||
datadf = dataprep.filter_df(datadf,'driveneergy',workmax,
|
||||
largerthan=False)
|
||||
|
||||
datadf.dropna(axis=0,how='any',inplace=True)
|
||||
|
||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||
datadf = datadf.sort_values(['date'])
|
||||
|
||||
if userid == 0:
|
||||
extratitle = ''
|
||||
else:
|
||||
u = User.objects.get(id=userid)
|
||||
extratitle = ' '+u.first_name+' '+u.last_name
|
||||
|
||||
|
||||
|
||||
script,div = interactive_boxchart(datadf,plotfield,
|
||||
extratitle=extratitle)
|
||||
|
||||
scripta = script.split('\n')[2:-1]
|
||||
script = ''.join(scripta)
|
||||
|
||||
|
||||
return JSONResponse({
|
||||
"script":script,
|
||||
"div":div,
|
||||
})
|
||||
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def boxplot_view(request,userid=0,
|
||||
options={
|
||||
@@ -4780,60 +5059,6 @@ def boxplot_view(request,userid=0,
|
||||
ids = [int(w.id) for w in workouts]
|
||||
request.session['ids'] = ids
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
}
|
||||
|
||||
|
||||
datemapping = {
|
||||
w.id:w.date for w in workouts
|
||||
}
|
||||
|
||||
|
||||
|
||||
fieldlist,fielddict = dataprep.getstatsfields()
|
||||
fieldlist = [plotfield,'workoutid','spm','driveenergy',
|
||||
'workoutstate']
|
||||
|
||||
# prepare data frame
|
||||
datadf = dataprep.read_cols_df_sql(ids,fieldlist)
|
||||
|
||||
datadf = dataprep.clean_df_stats(datadf,workstrokesonly=workstrokesonly)
|
||||
|
||||
datadf = dataprep.filter_df(datadf,'spm',spmmin,
|
||||
largerthan=True)
|
||||
datadf = dataprep.filter_df(datadf,'spm',spmmax,
|
||||
largerthan=False)
|
||||
datadf = dataprep.filter_df(datadf,'driveenergy',workmin,
|
||||
largerthan=True)
|
||||
datadf = dataprep.filter_df(datadf,'driveneergy',workmax,
|
||||
largerthan=False)
|
||||
|
||||
datadf.dropna(axis=0,how='any',inplace=True)
|
||||
|
||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||
datadf = datadf.sort_values(['date'])
|
||||
|
||||
if userid == 0:
|
||||
extratitle = ''
|
||||
else:
|
||||
u = User.objects.get(id=userid)
|
||||
extratitle = ' '+u.first_name+' '+u.last_name
|
||||
|
||||
|
||||
|
||||
script,div = interactive_boxchart(datadf,plotfield,
|
||||
extratitle=extratitle)
|
||||
|
||||
|
||||
return render(request,'boxplot.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'chartform':chartform,
|
||||
'userid':userid,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
else:
|
||||
return HttpResponse("Form is not valid")
|
||||
elif request.method == 'POST' and 'ids' in request.session:
|
||||
@@ -4849,80 +5074,35 @@ def boxplot_view(request,userid=0,
|
||||
workstrokesonly = not includereststrokes
|
||||
ids = request.session['ids']
|
||||
request.session['ids'] = ids
|
||||
workouts = dataprep.get_workouts(ids,userid)
|
||||
if not workouts:
|
||||
message = 'Error: Workouts in session storage do not belong to this user.'
|
||||
messages.error(request,message)
|
||||
url = reverse(user_boxplot_select,
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
}
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# workouts = [Workout.objects.get(id=id) for id in ids]
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__unicode__() for w in workouts
|
||||
}
|
||||
|
||||
datemapping = {
|
||||
w.id:w.date for w in workouts
|
||||
}
|
||||
|
||||
fieldlist,fielddict = dataprep.getstatsfields()
|
||||
fieldlist = [plotfield,'workoutid','spm','driveenergy',
|
||||
'workoutstate']
|
||||
|
||||
# prepare data frame
|
||||
datadf = dataprep.read_cols_df_sql(ids,fieldlist)
|
||||
|
||||
# dummy values for drive energy
|
||||
mask = datadf['driveenergy'] == 0
|
||||
datadf.loc[mask,'driveenergy'] = 450
|
||||
|
||||
datadf = dataprep.clean_df_stats(datadf,
|
||||
workstrokesonly=workstrokesonly)
|
||||
|
||||
|
||||
datadf = dataprep.filter_df(datadf,'spm',spmmin,
|
||||
largerthan=True)
|
||||
datadf = dataprep.filter_df(datadf,'spm',spmmax,
|
||||
largerthan=False)
|
||||
datadf = dataprep.filter_df(datadf,'driveenergy',workmin,
|
||||
largerthan=True)
|
||||
datadf = dataprep.filter_df(datadf,'driveneergy',workmax,
|
||||
largerthan=False)
|
||||
|
||||
datadf.dropna(axis=0,how='any',inplace=True)
|
||||
|
||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||
datadf = datadf.sort_values(['date'])
|
||||
|
||||
if userid == 0:
|
||||
extratitle = ''
|
||||
else:
|
||||
u = User.objects.get(id=userid)
|
||||
extratitle = ' '+u.first_name+' '+u.last_name
|
||||
|
||||
script,div = interactive_boxchart(datadf,plotfield,
|
||||
extratitle=extratitle)
|
||||
|
||||
|
||||
return render(request,'boxplot.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'chartform':chartform,
|
||||
'userid':userid,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
else:
|
||||
return HttpResponse("invalid form")
|
||||
else:
|
||||
url = reverse(user_boxplot_select)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
div = get_call()
|
||||
|
||||
options['spmmin'] = spmmin
|
||||
options['spmmax'] = spmmax
|
||||
options['workmin'] = workmin
|
||||
options['workmax'] = workmax
|
||||
options['ids'] = ids
|
||||
options['userid'] = userid
|
||||
options['plotfield'] = plotfield
|
||||
|
||||
request.session['options'] = options
|
||||
|
||||
return render(request,'boxplot.html',
|
||||
{'interactiveplot':'',
|
||||
'the_div':div,
|
||||
'chartform':chartform,
|
||||
'userid':userid,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
|
||||
# List Workouts
|
||||
@login_required()
|
||||
def workouts_view(request,message='',successmessage='',
|
||||
@@ -6646,12 +6826,8 @@ def workout_workflow_view(request,id):
|
||||
favorites = None
|
||||
maxfav = 0
|
||||
|
||||
charts = []
|
||||
charts = get_call()
|
||||
|
||||
if favorites and 'flexthumbnails.html' in r.workflowmiddlepanel:
|
||||
charts = thumbnails_set(r,id,favorites)
|
||||
if charts[0]['script'] == '':
|
||||
charts = []
|
||||
|
||||
if 'panel_map.html' in r.workflowmiddlepanel and rowhascoordinates(row):
|
||||
rowdata = rdata(row.csvfilename)
|
||||
|
||||
@@ -98,6 +98,14 @@ th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
cox {
|
||||
/* font-family: Georgia, serif; */
|
||||
font-weight: normal;
|
||||
/* padding-top: 20px; */
|
||||
text-align: center;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.listtable tbody tr:nth-of-type(even) { background-color: #DDD; }
|
||||
.listtable thead th {
|
||||
font-weight: bold;
|
||||
|
||||
Reference in New Issue
Block a user