added static plot of in stroke from geeky page
This commit is contained in:
@@ -7,122 +7,134 @@
|
||||
{% 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 %}
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<h1>Advanced OTW features</h1>
|
||||
{% if user.rower.rowerplan == 'basic' %}
|
||||
<p>This is a preview of the page with advanced functionality for Pro users. See <a href="/rowers/about">the About page</a> for more information and to sign up for Pro Membership</a>
|
||||
{% endif %}
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/export">Export</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<h1>Advanced OTW features</h1>
|
||||
{% if user.rower.rowerplan == 'basic' %}
|
||||
<p>This is a preview of the page with advanced functionality for Pro users. See <a href="/rowers/about">the About page</a> for more information and to sign up for Pro Membership</a>
|
||||
{% endif %}
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/export">Export</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th>Date:</th><td>{{ workout.date }}</td>
|
||||
</tr><tr>
|
||||
<th>Time:</th><td>{{ workout.starttime }}</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>
|
||||
<th>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
</table>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th>Date:</th><td>{{ workout.date }}</td>
|
||||
</tr><tr>
|
||||
<th>Time:</th><td>{{ workout.starttime }}</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>
|
||||
<th>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/wind">Edit Wind Data</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">Edit Wind Data</a>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
Add wind data for OTW workouts
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/stream">Edit Stream Data</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">Edit Stream Data</a>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
For river dwellers. Add stream information.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">OTW Power</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Run OTW Power calculations (wind & stream correction, equivalent erg pace)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/wind">Edit Wind Data</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">Edit Wind Data</a>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
Add wind data for OTW workouts
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/stream">Edit Stream Data</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">Edit Stream Data</a>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
For river dwellers. Add stream information.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">OTW Power</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Run OTW Power calculations (wind & stream correction, equivalent erg pace)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveotwplot">Corrected Pace Plot</a>
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveotwplot">Corrected Pace Plot</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/about">Corrected Pace Plot</a>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
Wind and Stream corrected pace plots will be here.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 suffix_2 omega">
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
Wind and Stream corrected pace plots will be here.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 suffix_2 omega">
|
||||
<p>
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveplot">Big Interactive Plot</a>
|
||||
</p>
|
||||
<p>
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
{% if instrokemetrics %}
|
||||
{% for metric in instrokemetrics %}
|
||||
{% if forloop.first %}
|
||||
<div class="grid_2 alpha">
|
||||
{% else %}
|
||||
<div class="grid_2">
|
||||
{% endif %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/instroke/{{ metric }}">{{ metric }}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
|
||||
@@ -223,6 +223,7 @@ urlpatterns = [
|
||||
url(r'^workout/(?P<id>\d+)/makepublic$',views.workout_makepublic_view),
|
||||
url(r'^workout/(?P<id>\d+)/geeky$',views.workout_geeky_view),
|
||||
url(r'^workout/(?P<id>\d+)/advanced$',views.workout_advanced_view),
|
||||
url(r'^workout/(?P<id>\d+)/instroke/(?P<metric>\w+.*)$',views.instroke_chart),
|
||||
url(r'^workout/(?P<id>\d+)/stats$',views.workout_stats_view),
|
||||
url(r'^workout/(?P<id>\d+)/otwsetpower$',views.workout_otwsetpower_view),
|
||||
url(r'^workout/(?P<id>\d+)/interactiveotwplot$',views.workout_otwpowerplot_view),
|
||||
|
||||
@@ -16,7 +16,8 @@ from django.db.models import Q
|
||||
from django import template
|
||||
from django.db import IntegrityError, transaction
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from matplotlib.backends.backend_agg import FigureCanvas
|
||||
import gc
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.http import (
|
||||
@@ -6445,6 +6446,10 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
form = WorkoutForm(instance=row)
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
rowdata = rrdata(csvfile=row.csvfilename)
|
||||
instrokemetrics = rowdata.get_instroke_columns()
|
||||
|
||||
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
@@ -6486,6 +6491,7 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||
{'workout':row,
|
||||
'teams':get_my_teams(request.user),
|
||||
'interactiveplot':script,
|
||||
'instrokemetrics':instrokemetrics,
|
||||
'the_div':div})
|
||||
else:
|
||||
return render(request,
|
||||
@@ -6495,6 +6501,60 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||
'interactiveplot':script,
|
||||
'the_div':div})
|
||||
|
||||
# generate instroke chart
|
||||
@login_required()
|
||||
def instroke_chart(request,id=0,metric=''):
|
||||
try:
|
||||
w = Workout.objects.get(id=id)
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("Workout doesn't exist")
|
||||
|
||||
if (checkworkoutuser(request.user,w)==False):
|
||||
message = "You are not allowed to edit this workout"
|
||||
messages.error(request,message)
|
||||
url = reverse(workouts_view)
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
rowdata = rrdata(csvfile=w.csvfilename)
|
||||
instrokemetrics = rowdata.get_instroke_columns()
|
||||
|
||||
if metric in instrokemetrics:
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = getrower(u)
|
||||
title = w.name
|
||||
fig1 = rowdata.get_plot_instroke(metric)
|
||||
canvas = FigureCanvas(fig1)
|
||||
canvas.print_figure('static/plots/'+imagename)
|
||||
plt.close(fig1)
|
||||
fig1.clf()
|
||||
gc.collect()
|
||||
|
||||
try:
|
||||
width,height = Image.open(fullpathimagename).size
|
||||
except:
|
||||
width = 1200
|
||||
height = 600
|
||||
|
||||
i = GraphImage(workout=w,
|
||||
creationdatetime=timezone.now(),
|
||||
filename=fullpathimagename,
|
||||
width=width,height=height)
|
||||
|
||||
i.save()
|
||||
print i.id,'aap'
|
||||
|
||||
url = reverse(workout_geeky_view,
|
||||
kwargs = {
|
||||
'id':id,
|
||||
})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Cumulative stats page
|
||||
@login_required()
|
||||
def cumstats(request,theuser=0,
|
||||
|
||||
Reference in New Issue
Block a user