workout_view
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
{% block title %}Change Workout {% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h1>Edit Workout Interval Data</h1>
|
||||
<h1>Split Workout</h1>
|
||||
|
||||
{% localtime on %}
|
||||
<ul class="main-content">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
{% block scripts %}
|
||||
@@ -16,183 +16,117 @@
|
||||
{% for graph in graphs1 %}
|
||||
{% block og_image %}
|
||||
{% if graphs1 %}
|
||||
{% for graph in graphs1 %}
|
||||
<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:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<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" />
|
||||
{% endif %}
|
||||
{% for graph in graphs %}
|
||||
<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:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<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" />
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block image_src %}
|
||||
{% for graph in graphs1 %}
|
||||
<link rel="image_src" href="/{{ graph.filename |spacetohtml }}" />
|
||||
{% for graph in graphs %}
|
||||
<link rel="image_src" href="/{{ graph.filename |spacetohtml }}" />
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% endfor %}
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
{% block main %}
|
||||
|
||||
|
||||
<h1>{{ workout.name }}</h1>
|
||||
<div class="grid_1 alpha">
|
||||
<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">
|
||||
<a class="twitter-share-button"
|
||||
href="https://twitter.com/intent/tweet"
|
||||
data-url="https://rowsandall.com/rowers/workout/{{ workout.id }}"
|
||||
data-text="@rowsandall #rowingdata">Tweet</a>
|
||||
</div>
|
||||
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<h1>{{ workout.name }}</h1>
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<p>
|
||||
<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>
|
||||
</p>
|
||||
<p>
|
||||
<a class="twitter-share-button"
|
||||
href="https://twitter.com/intent/tweet"
|
||||
data-url="https://rowsandall.com/rowers/workout/{{ workout.id }}"
|
||||
data-text="@rowsandall #rowingdata">Tweet</a>
|
||||
</p>
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th>Rower:</th><td>{{ first_name }} {{ last_name }}</td>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
<th>Name:</th><td>{{ workout.name }}</td>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
<th>Date:</th><td>{{ workout.date }}</td>
|
||||
</tr><tr>
|
||||
</tr><tr>
|
||||
<th>Time:</th><td>{{ workout.starttime }}</td>
|
||||
</tr><tr>
|
||||
</tr><tr>
|
||||
<th>Distance:</th><td>{{ workout.distance }}m</td>
|
||||
</tr><tr>
|
||||
</tr><tr>
|
||||
<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
||||
</tr><tr>
|
||||
</tr><tr>
|
||||
<th>Type:</th><td>{{ workout.workouttype }}</td>
|
||||
</tr><tr>
|
||||
</tr><tr>
|
||||
<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
|
||||
</tr>
|
||||
{% if user.is_authenticated %}
|
||||
<tr>
|
||||
<th>Comments</th>
|
||||
</tr>
|
||||
{% if user.is_authenticated %}
|
||||
<tr>
|
||||
<th>Comments</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}/comment">Comment ({{ aantalcomments }})</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
<h1>Workout Summary</h1>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
{{ workout.summary }}
|
||||
</pre>
|
||||
</p>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<h1>Workout Summary</h1>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
{{ workout.summary }}
|
||||
</pre>
|
||||
</p>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<div class="mapdiv">
|
||||
|
||||
{{ mapdiv|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>
|
||||
{% 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 %}
|
||||
|
||||
|
||||
{% 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 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);
|
||||
</div>
|
||||
</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>
|
||||
<style>
|
||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||
html, body {height: 100%; margin:5px;}
|
||||
</style>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
{{ 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 %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_workout.html' %}
|
||||
{% endblock %}
|
||||
|
||||
155
rowers/views.py
155
rowers/views.py
@@ -6596,99 +6596,100 @@ def workout_fusion_list(request,id=0,message='',successmessage='',
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("User has no rower instance")
|
||||
|
||||
# Basic 'EDIT' view of workout
|
||||
# Basic view of workout
|
||||
def workout_view(request,id=0):
|
||||
request.session['referer'] = absolute(request)['PATH']
|
||||
|
||||
try:
|
||||
# check if valid ID exists (workout exists)
|
||||
row = Workout.objects.get(id=id)
|
||||
comments = WorkoutComment.objects.filter(workout=row)
|
||||
|
||||
aantalcomments = len(comments)
|
||||
|
||||
|
||||
if row.privacy == 'private':
|
||||
raise PermissionDenied("Access denied")
|
||||
if not request.user.is_anonymous():
|
||||
rower = getrower(request.user)
|
||||
else:
|
||||
rower = None
|
||||
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
row = Workout.objects.get(id=id)
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("Workout doesn't exist")
|
||||
|
||||
comments = WorkoutComment.objects.filter(workout=row)
|
||||
|
||||
aantalcomments = len(comments)
|
||||
|
||||
|
||||
if row.privacy == 'private' and not checkworkoutuser(request.user,row):
|
||||
raise PermissionDenied("Access denied")
|
||||
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
r = Rower.objects.get(id=row.user.id)
|
||||
u = User.objects.get(id=r.user.id)
|
||||
|
||||
|
||||
# create interactive plot
|
||||
res = interactive_chart(id)
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
# create interactive plot
|
||||
res = interactive_chart(id)
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
|
||||
# create map
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = getrower(u)
|
||||
rowdata = rdata(f1)
|
||||
hascoordinates = 1
|
||||
if rowdata != 0:
|
||||
try:
|
||||
latitude = rowdata.df[' latitude']
|
||||
if not latitude.std():
|
||||
hascoordinates = 0
|
||||
except KeyError,AttributeError:
|
||||
# create map
|
||||
f1 = row.csvfilename
|
||||
rowdata = rdata(f1)
|
||||
hascoordinates = 1
|
||||
if rowdata != 0:
|
||||
try:
|
||||
latitude = rowdata.df[' latitude']
|
||||
if not latitude.std():
|
||||
hascoordinates = 0
|
||||
|
||||
else:
|
||||
except KeyError,AttributeError:
|
||||
hascoordinates = 0
|
||||
|
||||
else:
|
||||
hascoordinates = 0
|
||||
|
||||
if hascoordinates:
|
||||
mapscript,mapdiv = leaflet_chart(rowdata.df[' latitude'],
|
||||
rowdata.df[' longitude'],
|
||||
row.name)
|
||||
|
||||
if hascoordinates:
|
||||
mapscript,mapdiv = leaflet_chart(rowdata.df[' latitude'],
|
||||
rowdata.df[' longitude'],
|
||||
row.name)
|
||||
|
||||
|
||||
else:
|
||||
mapscript = ""
|
||||
mapdiv = ""
|
||||
else:
|
||||
mapscript = ""
|
||||
mapdiv = ""
|
||||
|
||||
|
||||
# render page
|
||||
if (len(g)<=3):
|
||||
return render(request, 'workout_view.html',
|
||||
{'workout':row,
|
||||
'graphs1':g[0:3],
|
||||
'last_name':u.last_name,
|
||||
'first_name':u.first_name,
|
||||
'interactiveplot':script,
|
||||
'aantalcomments':aantalcomments,
|
||||
'mapscript':mapscript,
|
||||
'mapdiv':mapdiv,
|
||||
'teams':get_my_teams(request.user),
|
||||
'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})
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':'/rowers/list-workouts',
|
||||
'name':'Workouts'
|
||||
},
|
||||
{
|
||||
'url':reverse(workout_view,kwargs={'id':id}),
|
||||
'name': id,
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("Workout doesn't exist")
|
||||
u = row.user.user
|
||||
|
||||
return render(request, 'workout_view.html',
|
||||
{'workout':row,
|
||||
'rower':rower,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'active':'nav-workouts',
|
||||
'graphs':g,
|
||||
'last_name':u.last_name,
|
||||
'first_name':u.first_name,
|
||||
'interactiveplot':script,
|
||||
'aantalcomments':aantalcomments,
|
||||
'mapscript':mapscript,
|
||||
'mapdiv':mapdiv,
|
||||
'teams':get_my_teams(request.user),
|
||||
'the_div':div})
|
||||
|
||||
|
||||
# Resets stroke data to raw data (pace)
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
|
||||
Reference in New Issue
Block a user