Private
Public Access
1
0

splitworkout

This commit is contained in:
Sander Roosendaal
2018-10-09 10:14:07 +02:00
parent 50321b850a
commit 864ea2883d
4 changed files with 79 additions and 120 deletions

View File

@@ -1,131 +1,77 @@
{% 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 %}
{% block main %}
<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 }}/export">Export</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 %}
<p>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/split" 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="Split">
</div>
</form>
</p>
<h1>Workout Split</h1>
<p>Split your workout in half at the given time using the form above.
Use the chart on
the right to find the point where you want to split.</p>
<p>Use any of the following formats:
<ul>
<li>H:MM:SS.d, e.g. 1:45:00.0 for one hour and 45 minutes</li>
<li>H:MM:SS, e.g. 1:45:00 for one hour and 45 minutes</li>
<li>MM:SS.d, e.g. 30:00.0 for thirty minutes</li>
<li>MM, e.g. 30 for thirty minutes</li>
</ul>
</p>
<p>Warning: If you deselect, "Keep Original", the original workout
cannot be restored afterwards.</p>
</div>
<div id="advancedplots" class="grid_6 omega">
<div class="grid_6 alpha">
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/split" method="post">
<table width=100%>
{{ form.as_table }}
</table>
{% csrf_token %}
<input class="button green" type="submit" value="Split">
</form>
</p>
</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>
{{ thescript |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">
<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>
{{ thescript |safe }}
{{ thediv |safe }}
</div>
<table width=100%>
<tr>
<th>Date/Time:</th><td>{{ workout.startdatetime }}</td>
</tr><tr>
<th>Distance:</th><td>{{ workout.distance }}m</td>
</tr><tr>
<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
</tr><tr>
<th>Public link to this workout</th>
<td>
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
<td>
</tr><tr>
<th>Public link to interactive chart</th>
<td>
<a href="/rowers/workout/{{ workout.id }}/interactiveplot">https://rowsandall.com/rowers/workout/{{ workout.id }}/interactiveplot</a>
<td>
</tr>
</table>
{% endlocaltime %}
<tr>
<th>Date/Time:</th><td>{{ workout.startdatetime }}</td>
</tr><tr>
<th>Distance:</th><td>{{ workout.distance }}m</td>
</tr><tr>
<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
</tr><tr>
<th>Public link to this workout</th>
<td>
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
<td>
</tr>
</table>
{% endlocaltime %}
</li>
<li class="grid_4">
<h1>Workout Split</h1>
<p>Split your workout in half at the given time using the form above.
Use the chart on
the right to find the point where you want to split.</p>
<p>Use any of the following formats:
<ul>
<li>H:MM:SS.d, e.g. 1:45:00.0 for one hour and 45 minutes</li>
<li>H:MM:SS, e.g. 1:45:00 for one hour and 45 minutes</li>
<li>MM:SS.d, e.g. 30:00.0 for thirty minutes</li>
<li>MM, e.g. 30 for thirty minutes</li>
</ul>
</p>
<p>
Warning: If you deselect, "Keep Original", the original workout
cannot be restored afterwards.
</p>
</li>
</ul>
</div>
</div>
{% endblock %}
{% block sidebar %}
{% include 'menu_workout.html' %}
{% endblock %}

View File

@@ -21,11 +21,6 @@
<td>
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
<td>
</tr><tr>
<th>Public link to interactive chart</th>
<td>
<a href="/rowers/workout/{{ workout.id }}/interactiveplot">https://rowsandall.com/rowers/workout/{{ workout.id }}/interactiveplot</a>
<td>
</tr>
</table>
<h1>Interval Shorthand</h1>

View File

@@ -259,7 +259,7 @@ urlpatterns = [
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),
url(r'^workout/(?P<id>\d+)/interactiveplot$',views.workout_biginteractive_view),
# url(r'^workout/(?P<id>\d+)/interactiveplot$',views.workout_biginteractive_view),
url(r'^workout/(?P<id>\d+)/view$',views.workout_view),
url(r'^workout/(?P<id>\d+)$',views.workout_view),
url(r'^workout/fusion/(?P<id1>\d+)/(?P<id2>\d+)$',views.workout_fusion_view),

View File

@@ -10933,6 +10933,21 @@ def workout_split_view(request,id=id):
r = row.user
breadcrumbs = [
{
'url':'/rowers/list-workouts',
'name':'Workouts'
},
{
'url':get_workout_default_page(request,row.id),
'name': str(row.id)
},
{
'url':reverse(graph_show_view,kwargs={'id':id}),
'name': 'Chart'
}
]
if request.method == 'POST':
form = WorkoutSplitForm(request.POST)
if form.is_valid():
@@ -10993,6 +11008,9 @@ def workout_split_view(request,id=id):
return render(request, 'splitworkout.html',
{'form':form,
'rower':r,
'breadcrumbs':breadcrumbs,
'active':'nav-workouts',
'workout':row,
'thediv':script,
'thescript':div,