Private
Public Access
1
0

workout_view

This commit is contained in:
Sander Roosendaal
2018-10-09 10:44:35 +02:00
parent 864ea2883d
commit ffa523851e
3 changed files with 164 additions and 229 deletions

View File

@@ -6,7 +6,7 @@
{% block title %}Change Workout {% endblock %} {% block title %}Change Workout {% endblock %}
{% block main %} {% block main %}
<h1>Edit Workout Interval Data</h1> <h1>Split Workout</h1>
{% localtime on %} {% localtime on %}
<ul class="main-content"> <ul class="main-content">

View File

@@ -1,4 +1,4 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load rowerfilters %} {% load rowerfilters %}
{% block scripts %} {% block scripts %}
@@ -16,40 +16,45 @@
{% for graph in graphs1 %} {% for graph in graphs1 %}
{% block og_image %} {% block og_image %}
{% if graphs1 %} {% if graphs1 %}
{% for graph in graphs1 %} {% for graph in graphs %}
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" /> <meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" /> <meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" />
<meta property="og:image:width" content="{{ graph.width }}" /> <meta property="og:image:width" content="{{ graph.width }}" />
<meta property="og:image:height" content="{{ graph.height }}" /> <meta property="og:image:height" content="{{ graph.height }}" />
{% endfor %} {% endfor %}
{% else %} {% else %}
<meta property="og:image" content="http://rowsandall.com/static/img/logo_r.png" /> <meta property="og:image" content="http://rowsandall.com/static/img/logo_r.png" />
<meta property="og:image:secure_url" content="https://rowsandall.com/static/img/logo_r.png" /> <meta property="og:image:secure_url" content="https://rowsandall.com/static/img/logo_r.png" />
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block image_src %} {% block image_src %}
{% for graph in graphs1 %} {% for graph in graphs %}
<link rel="image_src" href="/{{ graph.filename |spacetohtml }}" /> <link rel="image_src" href="/{{ graph.filename |spacetohtml }}" />
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
{% endfor %} {% endfor %}
{% block content %} {% block main %}
<div id="workouts" class="grid_6 alpha">
<h1>{{ workout.name }}</h1>
<h1>{{ workout.name }}</h1> <ul class="main-content">
<div class="grid_1 alpha"> <li class="grid_2">
<div class="fb-share-button" data-href="https://rowsandall.com/rowers/workout/{{ workout.id }}" data-layout="button" data-size="small" data-mobile-iframe="false"> <p>
<a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://rowsandall.com/rowers/workout/{{ workout.id }}">Share</a></div> <div class="fb-share-button"
data-href="https://rowsandall.com/rowers/workout/{{ workout.id }}"
data-layout="button" data-size="small" data-mobile-iframe="false">
<a class="fb-xfbml-parse-ignore" target="_blank"
href="https://www.facebook.com/sharer/sharer.php?u=https://rowsandall.com/rowers/workout/{{ workout.id }}">
Share
</a>
</div> </div>
<div class="grid_1"> </p>
<p>
<a class="twitter-share-button" <a class="twitter-share-button"
href="https://twitter.com/intent/tweet" href="https://twitter.com/intent/tweet"
data-url="https://rowsandall.com/rowers/workout/{{ workout.id }}" data-url="https://rowsandall.com/rowers/workout/{{ workout.id }}"
data-text="@rowsandall #rowingdata">Tweet</a> data-text="@rowsandall #rowingdata">Tweet</a>
</div> </p>
<table width=100%> <table width=100%>
<tr> <tr>
<th>Rower:</th><td>{{ first_name }} {{ last_name }}</td> <th>Rower:</th><td>{{ first_name }} {{ last_name }}</td>
@@ -79,89 +84,26 @@
</tr> </tr>
{% endif %} {% endif %}
</table> </table>
</li>
<li class="grid_2">
<h1>Workout Summary</h1> <h1>Workout Summary</h1>
<p> <p>
<pre> <pre>
{{ workout.summary }} {{ workout.summary }}
</pre> </pre>
</p> </p>
</li>
<li class="grid_2">
<div class="mapdiv">
{{ mapdiv|safe }} {{ mapdiv|safe }}
{{ mapscript|safe }} {{ mapscript|safe }}
</div>
<div id="images" class="grid_6 omega">
<h1>Images linked to this workout</h1>
{% if graphs1 %}
{% for graph in graphs1 %}
{% if forloop.counter == 1 %}
<div id="thumb-container" class="grid_2 alpha">
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100"></a>
</div> </div>
{% elif forloop.counter == 3 %} </li>
<div id="thumb-container" class="grid_2 omega"> <li class="grid_2">
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100"></a>
</div>
{% else %}
<div id="thumb-container" class="grid_2">
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100"></a>
</div>
{% endif %}
{% endfor %}
{% for graph in graphs2 %}
{% if forloop.counter == 1 %}
<div id="thumb-container" class="grid_2 alpha">
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100"></a>
</div>
{% elif forloop.counter == 3 %}
<div id="thumb-container" class="grid_2 omega">
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100"></a>
</div>
{% else %}
<div id="thumb-container" class="grid_2">
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100"></a>
</div>
{% endif %}
{% endfor %}
{% else %}
<p> No graphs found </p>
{% endif %}
</div>
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script> <script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
<script async="true" type="text/javascript"> <script async="true" type="text/javascript">
Bokeh.set_log_level("info"); Bokeh.set_log_level("info");
@@ -169,30 +111,22 @@
{{ interactiveplot |safe }} {{ 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 }} {{ the_div|safe }}
</div> </li>
{% for graph in graphs %}
<li>
<a href="/rowers/graph/{{ graph.id }}/">
<img src="/{{ graph.filename }}"
onerror="this.src='/static/img/rowingtimer.gif'"
alt="{{ graph.filename }}" width="120" height="100">
</a>
</li>
{% endfor %}
</ul>
{% endblock %} {% endblock %}
{% block sidebar %}
{% include 'menu_workout.html' %}
{% endblock %}

View File

@@ -6596,19 +6596,26 @@ def workout_fusion_list(request,id=0,message='',successmessage='',
except Rower.DoesNotExist: except Rower.DoesNotExist:
raise Http404("User has no rower instance") raise Http404("User has no rower instance")
# Basic 'EDIT' view of workout # Basic view of workout
def workout_view(request,id=0): def workout_view(request,id=0):
request.session['referer'] = absolute(request)['PATH'] request.session['referer'] = absolute(request)['PATH']
if not request.user.is_anonymous():
rower = getrower(request.user)
else:
rower = None
try: try:
# check if valid ID exists (workout exists)
row = Workout.objects.get(id=id) row = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
comments = WorkoutComment.objects.filter(workout=row) comments = WorkoutComment.objects.filter(workout=row)
aantalcomments = len(comments) aantalcomments = len(comments)
if row.privacy == 'private': if row.privacy == 'private' and not checkworkoutuser(request.user,row):
raise PermissionDenied("Access denied") raise PermissionDenied("Access denied")
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime") g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
@@ -6621,8 +6628,6 @@ def workout_view(request,id=0):
except: except:
pass pass
r = Rower.objects.get(id=row.user.id)
u = User.objects.get(id=r.user.id)
# create interactive plot # create interactive plot
@@ -6632,8 +6637,6 @@ def workout_view(request,id=0):
# create map # create map
f1 = row.csvfilename f1 = row.csvfilename
u = row.user.user
r = getrower(u)
rowdata = rdata(f1) rowdata = rdata(f1)
hascoordinates = 1 hascoordinates = 1
if rowdata != 0: if rowdata != 0:
@@ -6658,12 +6661,26 @@ def workout_view(request,id=0):
mapscript = "" mapscript = ""
mapdiv = "" mapdiv = ""
breadcrumbs = [
{
'url':'/rowers/list-workouts',
'name':'Workouts'
},
{
'url':reverse(workout_view,kwargs={'id':id}),
'name': id,
}
]
u = row.user.user
# render page
if (len(g)<=3):
return render(request, 'workout_view.html', return render(request, 'workout_view.html',
{'workout':row, {'workout':row,
'graphs1':g[0:3], 'rower':rower,
'breadcrumbs':breadcrumbs,
'active':'nav-workouts',
'graphs':g,
'last_name':u.last_name, 'last_name':u.last_name,
'first_name':u.first_name, 'first_name':u.first_name,
'interactiveplot':script, 'interactiveplot':script,
@@ -6672,24 +6689,8 @@ def workout_view(request,id=0):
'mapdiv':mapdiv, 'mapdiv':mapdiv,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'the_div':div}) 'the_div':div})
else:
return render(request, 'workout_view.html',
{'workout':row,
'graphs1':g[0:3],
'graphs2':g[3:6],
'last_name':u.last_name,
'first_name':u.first_name,
'teams':get_my_teams(request.user),
'aantalcomments':aantalcomments,
'mapscript':mapscript,
'mapdiv':mapdiv,
'interactiveplot':script,
'the_div':div})
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
# Resets stroke data to raw data (pace) # Resets stroke data to raw data (pace)
@user_passes_test(ispromember,login_url="/",redirect_field_name=None) @user_passes_test(ispromember,login_url="/",redirect_field_name=None)
def workout_undo_smoothenpace_view( def workout_undo_smoothenpace_view(