Private
Public Access
1
0

edit intervals

This commit is contained in:
Sander Roosendaal
2018-10-09 08:40:57 +02:00
parent 4b52a90806
commit 50321b850a
3 changed files with 121 additions and 198 deletions

View File

@@ -1,46 +1,17 @@
{% extends "base.html" %}
{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% load tz %}
{% block title %}Change Workout {% endblock %}
{% block content %}
<div id="workouts" class="grid_6 alpha">
{% if form.errors %}
<p style="color: red;">
Please correct the error{{ form.errors|pluralize }} below.
</p>
{% endif %}
<h1>Edit Workout Interval Data</h1>
<div class="grid_6 alpha">
<div class="grid_2 alpha">
<p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit</a>
</p>
</div>
<div class="grid_2">
<p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/workflow">Workflow View</a>
</p>
</div>
<div class="grid_2 omega tooltip">
<p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced</a>
</p>
<span class="tooltiptext">Advanced Functionality (More interactive Charts)</span>
</div>
</div>
{% localtime on %}
{% block main %}
<h1>Edit Workout Interval Data</h1>
<ul class="main-content">
<li class="grid_2">
<table width=100%>
<tr>
<th>Date/Time:</th><td>{{ workout.startdatetime }}</td>
<th>Name</th><td>{{ workout.name }}</td>
</tr><tr>
<th>Distance:</th><td>{{ workout.distance }}m</td>
</tr><tr>
@@ -57,8 +28,72 @@
<td>
</tr>
</table>
{% endlocaltime %}
<h1>Interval Translator</h1>
<h1>Interval Shorthand</h1>
<p>
See the how-to <a href="#howto">at the bottom of this page</a> for details on how to use this form.
</p>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/editintervals" method="post">
<table width=100%>
{{ form.as_table }}
</table>
{% csrf_token %}
<input class="button green" type="submit" value="Update">
</form>
<h1>Intervals by Power/Pace</h1>
<p>With this form, you can specify a power or pace level. Everything faster/harder than the
specified pace/power will become a work interval. Everything slower will become a rest
interval.
</p>
<form ecntype="multipart/form-data" method="post">
<table>
{{ powerupdateform.as_table }}
</table>
{% csrf_token %}
<input class="button green" type="submit" value="Submit">
</form>
</li>
<li class="grid_2">
<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 }}
{{ the_div |safe }}
</li>
<li class="grid_2">
<h1>Updated Summary</h1>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/editintervals" method="post">
{% csrf_token %}
<input type="hidden" name="{{ savebutton }}" value="{{ intervalstring }}">
<input type="hidden" name="nrintervals" value={{ nrintervals }}>
{% for key,value in formvalues.items %}
<input type="hidden" name="{{ key }}" value="{{ value|safe }}">
{% endfor %}
{% for field in detailform %}
{{ field.as_hidden }}
{% endfor %}
<p>
<input class="button green" type="submit" value="Save">
</p>
<span>
<a href="">Reset to last saved</a>
&nbsp;
<a href="/rowers/workout/{{ workout.id }}/restore">Restore Original data</a>
</span>
</form>
<p>
<pre>
{{ intervalstats }}
</pre>
</p>
</li>
<li class="grid_4">
<h1 id="howto">Interval Shorthand How-To</h1>
<p>This is a quick way to enter the intervals using a special mini-language.</p>
<p>You enter something like <em>8x500m/3min</em>, press "Update" and the site will interpret this for you and update the summary on the right. If you're happy with the result, press the green Save button to update the values. Nothing will be changed permanently until you hit Save.</p>
@@ -89,142 +124,11 @@
<td>2x500m/500m</td><td>A 2k rowed as 500m "on", 500m "off"</td>
</tr>
</table>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/editintervals" method="post">
<table width=100%>
{{ form.as_table }}
</table>
{% csrf_token %}
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
<input class="button green" type="submit" value="Update">
</div>
</form>
<h1>Intervals by Power/Pace</h1>
<p>With this form, you can specify a power or pace level. Everything faster/harder than the
specified pace/power will become a work interval. Everything slower will become a rest
interval.
</p>
<form ecntype="multipart/form-data" method="post">
<table>
{{ powerupdateform.as_table }}
</table>
{% csrf_token %}
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
<input class="button green" type="submit" value="Submit">
</div>
</form>
</div>
<div id="advancedplots" class="grid_6 omega">
<div class="grid_6 alpha">
<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, true, true);
};
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="interactiveplot" class="grid_6 omega">
{{ the_div |safe }}
</div>
</div>
<div id="summary" class="grid_6 omega">
<h1>Updated Summary</h1>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/editintervals" method="post">
{% csrf_token %}
<input type="hidden" name="{{ savebutton }}" value="{{ intervalstring }}">
<input type="hidden" name="nrintervals" value={{ nrintervals }}>
{% for key,value in formvalues.items %}
<input type="hidden" name="{{ key }}" value="{{ value|safe }}">
{% endfor %}
{% for field in detailform %}
{{ field.as_hidden }}
{% endfor %}
<div class="grid_1 alpha">
<input class="button green" type="submit" value="Save">
</div>
<div class="grid_2">
<a class="button green" href="">Reset to last saved</a>
</div>
<div class="grid_2 omega">
<a class="button green" href="/rowers/workout/{{ workout.id }}/restore">Restore Original data</a>
</div>
</form>
<div class="grid_6 alpha">
<p>
<pre>
{{ intervalstats }}
</pre>
</p>
</div>
</div>
<div id="summary" class="grid_6 omega">
<h1>Detailed Summary Edit</h1>
<p>This is still experimental and there are known bugs. Use at your own risk. Nothing is stored permanently until you hit Save on the summary above. You can use the restore original button to restore the original values.</p>
<div class="grid_6 alpha">
<div class="grid_1 alpha"><strong>#</strong></div>
<div class="grid_1">
<strong>Time</strong>
</div>
<div class="grid_1">
<strong>Distance</strong>
</div>
<div class="grid_1 suffix_2 omega">
<strong>Type</strong>
</div>
</div>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/editintervals" method="post">
{% for i in nrintervals|times %}
<div class="grid_6 alpha">
<div class="grid_1 alpha">{{ i }}</div>
<div class="grid_1">
{% get_field_id i "intervalt_" detailform %}
</div>
<div class="grid_1">
{% get_field_id i "intervald_" detailform %}
</div>
<div class="grid_2 suffix_1 omega">
{% get_field_id i "type_" detailform %}
</div>
</div>
{% endfor %}
{% csrf_token %}
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
<input type="hidden" name="nrintervals" value={{ nrintervals }}>
<input class="button green" type="submit" value="Update">
</div>
</form>
</div>
</div>
</li>
</ul>
{% endblock %}
{% block sidebar %}
{% include 'menu_workout.html' %}
{% endblock %}

View File

@@ -255,7 +255,7 @@ urlpatterns = [
url(r'^workout/(?P<id>\d+)/darkskywind$',views.workout_downloadwind_view),
url(r'^workout/(?P<id>\d+)/metar/(?P<airportcode>\w+)$',views.workout_downloadmetar_view),
url(r'^workout/(?P<id>\d+)/stream$',views.workout_stream_view),
url(r'^workout/(?P<id>\d+)/crewnerdsummary$',views.workout_crewnerd_summary_view),
# url(r'^workout/(?P<id>\d+)/crewnerdsummary$',views.workout_crewnerd_summary_view),
url(r'^workout/(?P<id>\d+)/editintervals$',views.workout_summary_edit_view),
url(r'^workout/(?P<id>\d+)/restore$',views.workout_summary_restore_view),
url(r'^workout/(?P<id>\d+)/split$',views.workout_split_view),

View File

@@ -11066,6 +11066,22 @@ def workout_fusion_view(request,id1=0,id2=1):
def workout_summary_edit_view(request,id,message="",successmessage=""
):
row = get_workout_permitted(request.user,id)
r = getrower(request.user)
breadcrumbs = [
{
'url':'/rowers/list-workouts',
'name':'Workouts'
},
{
'url':get_workout_default_page(request,row.id),
'name': str(row.id)
},
{
'url':reverse(workout_summary_edit_view,kwargs={'id':id}),
'name': 'Edit Intervals'
}
]
s = ""
# still here - this is a workout we may edit
@@ -11443,6 +11459,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'detailform':detailform,
'powerupdateform':powerupdateform,
'workout':row,
'rower':r,
'breadcrumbs':breadcrumbs,
'active':'nav-workouts',
'teams':get_my_teams(request.user),
'intervalstats':intervalstats,
'nrintervals':nrintervals,