Added histogram for single workout
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
|
||||
<h1>Advanced Workout Editor</h1>
|
||||
{% if user.rower.rowerplan == 'basic' %}
|
||||
<p>This is a preview of the page with advanced functionality for Pro users. See <a href="/rowers/promembership">the page about Pro membership</a> for more information and to sign up for Pro Membership</a>
|
||||
<p>This is a preview of the page with advanced functionality for Pro users.
|
||||
See
|
||||
<a href="/rowers/promembership">the page about Pro membership</a> for more information and to sign up for Pro Membership</a>
|
||||
{% endif %}
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
@@ -117,6 +119,21 @@ Enter or change the interval and summary data for your workout
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<div class="grid_2 suffix_4 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/histo">Power Histogram</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Dist Metrics Plot</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Plot the Power Histogram of this workout
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
|
||||
66
rowers/templates/histo_single.html
Normal file
66
rowers/templates/histo_single.html
Normal file
@@ -0,0 +1,66 @@
|
||||
{% extends "base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}View Workout {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<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
|
||||
// the arguments of resize_width_height() to change the plot's behavior.
|
||||
var plot_resize_setup = function () {
|
||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||
var plot = Bokeh.index[plotid];
|
||||
var plotresizer = function() {
|
||||
// arguments: use width, use height, maintain aspect ratio
|
||||
plot.resize_width_height(true, false, false);
|
||||
};
|
||||
window.addEventListener('resize', plotresizer);
|
||||
plotresizer();
|
||||
};
|
||||
window.addEventListener('load', plot_resize_setup);
|
||||
</script>
|
||||
<style>
|
||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||
html, body {height: 100%; margin:5px;}
|
||||
</style>
|
||||
|
||||
|
||||
<div id="navigation" class="grid_12 alpha">
|
||||
{% if user.is_authenticated and mayedit %}
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 suffix_8 omega">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="title" class="grid_12 alpha">
|
||||
<h1>Indoor Rower Power Histogram</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="graph" class="grid_12 alpha">
|
||||
|
||||
{{ the_div|safe }}
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -425,6 +425,9 @@ class ViewTest(TestCase):
|
||||
response = self.c.get('/rowers/workout/1/interactiveplot', form_data, follow=True)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.c.get('/rowers/workout/1/histo', form_data, follow=True)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
|
||||
w = Workout.objects.get(id=1)
|
||||
|
||||
@@ -56,6 +56,7 @@ urlpatterns = [
|
||||
url(r'^graph/(\d+)/delete$',views.graph_delete_view),
|
||||
url(r'^workout/upload/$',views.workout_upload_view),
|
||||
url(r'^workout/upload/(.+.*)$',views.workout_upload_view),
|
||||
url(r'^workout/(?P<id>\d+)/histo$',views.workout_histo_view),
|
||||
url(r'^workout/(?P<id>\d+)/export/c/(?P<message>\w+.*)/s/(?P<successmessage>\w+.*)$',views.workout_export_view),
|
||||
url(r'^workout/(?P<id>\d+)/export/c/(?P<message>\w+.*)$',views.workout_export_view),
|
||||
url(r'^workout/(?P<id>\d+)/export/s/(?P<successmessage>\w+.*)$',views.workout_export_view),
|
||||
|
||||
@@ -1342,6 +1342,36 @@ def cum_flex(request,theuser=0,
|
||||
'promember':promember,
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def workout_histo_view(request,id=0):
|
||||
row = Workout.objects.get(id=id)
|
||||
promember=0
|
||||
mayedit=0
|
||||
if not request.user.is_anonymous():
|
||||
r = Rower.objects.get(user=request.user)
|
||||
result = request.user.is_authenticated() and r.rowerplan=='pro'
|
||||
if result:
|
||||
promember=1
|
||||
if request.user == row.user.user:
|
||||
mayedit=1
|
||||
|
||||
if not promember:
|
||||
return HttpResponseRedirect("/rowers/about/")
|
||||
|
||||
|
||||
|
||||
|
||||
res = interactive_histoall([row])
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
|
||||
return render(request,
|
||||
'histo_single.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'id':id,
|
||||
'mayedit':mayedit,
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def histo(request,theuser=0,
|
||||
|
||||
Reference in New Issue
Block a user