Private
Public Access
1
0

Flex buttons on workouts list

This commit is contained in:
Sander Roosendaal
2016-12-09 19:49:18 +01:00
parent 14e67a07eb
commit e5cb8b856d
3 changed files with 77 additions and 68 deletions

View File

@@ -1,3 +1,4 @@
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage
from rowingdata import rower as rrower from rowingdata import rower as rrower
from rowingdata import main as rmain from rowingdata import main as rmain

View File

@@ -26,77 +26,79 @@
<h1>My Workouts</h1> <h1>My Workouts</h1>
{% if workouts %} {% if workouts %}
<table width="70%" class="listtable"> <table width="70%" class="listtable">
<thead> <thead>
<tr> <tr>
<th> Date</th> <th> Date</th>
<th> Time</th> <th> Time</th>
<th> Name</th> <th> Name</th>
<th> Type</th> <th> Type</th>
<th> Distance </th> <th> Distance </th>
<th> Duration </th> <th> Duration </th>
<th> Avg HR </th> <th> Avg HR </th>
<th> Max HR </th> <th> Max HR </th>
<th> Delete</th> <th> Delete</th>
<th> Export</th> <th> Export</th>
</tr> </tr>
</thead> </thead>
</tbody> </tbody>
{% for workout in workouts %} {% for workout in workouts %}
<tr> <tr>
<td> {{ workout.date }} </td> <td> {{ workout.date }} </td>
<td> {{ workout.starttime }} </td> <td> {{ workout.starttime }} </td>
<td> <td>
{% if user.rower.rowerplan == 'pro' %} {% if user.rower.rowerplan == 'pro' %}
<a href="/rowers/workout/{{ workout.id }}/edit">{{ workout.name }}</a> </td> <a href="/rowers/workout/{{ workout.id }}/edit">{{ workout.name }}</a> </td>
{% else %} {% else %}
<a href="/rowers/workout/{{ workout.id }}/edit">{{ workout.name }}</a> </td> <a href="/rowers/workout/{{ workout.id }}/edit">{{ workout.name }}</a> </td>
{% endif %} {% endif %}
<td> {{ workout.workouttype }} </td> <td> {{ workout.workouttype }} </td>
<td> {{ workout.distance }}m</td> <td> {{ workout.distance }}m</td>
<td> {{ workout.duration |durationprint:"%H:%M:%S.%f" }} </td> <td> {{ workout.duration |durationprint:"%H:%M:%S.%f" }} </td>
<td> {{ workout.averagehr }} </td> <td> {{ workout.averagehr }} </td>
<td> {{ workout.maxhr }} </td> <td> {{ workout.maxhr }} </td>
<td> <a class="button red small" href="/rowers/workout/{{ workout.id }}/deleteconfirm">Delete</td> <td> <a class="button red small" href="/rowers/workout/{{ workout.id }}/deleteconfirm">Delete</td>
<td> <a class="button blue small" href="/rowers/workout/{{ workout.id }}/export">Export</a> </td> <td> <a class="button blue small" href="/rowers/workout/{{ workout.id }}/export">Export</a> </td>
<td> <a class="button blue small" href="/rowers/workout/{{ workout.id }}/flexchart">Flex</a> </td>
</tr>
</tr>
{% endfor %}
</tbody> {% endfor %}
</table> </tbody>
{% else %} </table>
<p> No workouts found </p> {% else %}
{% endif %} <p> No workouts found </p>
{% endif %}
</div> </div>
<div class="grid_6 alpha"> <div class="grid_6 alpha">
<form id="searchform" action="/rowers/list-workouts/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}" <form id="searchform" action="/rowers/list-workouts/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
method="get" accept-charset="utf-8"> method="get" accept-charset="utf-8">
<div class="grid_3 prefix_1 alpha"> <div class="grid_3 prefix_1 alpha">
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search"> <input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
</div> </div>
<div class="grid_1 suffix_1 omega"> <div class="grid_1 suffix_1 omega">
<button class="button blue small" type="submit"> <button class="button blue small" type="submit">
Search Search
</button> </button>
</div> </div>
</form> </form>
</div> </div>
<div class="grid_2 prefix_3 omega"> <div class="grid_2 prefix_3 omega">
<span class="button gray small"> <span class="button gray small">
{% if workouts.has_previous %} {% if workouts.has_previous %}
<a class="wh" href="?page={{ workouts.previous_page_number }}">&lt;</a> <a class="wh" href="?page={{ workouts.previous_page_number }}">&lt;</a>
{% endif %} {% endif %}
<span> <span>
Page {{ workouts.number }} of {{ workouts.paginator.num_pages }}. Page {{ workouts.number }} of {{ workouts.paginator.num_pages }}.
</span> </span>
{% if workouts.has_next %} {% if workouts.has_next %}
<a class="wh" href="?page={{ workouts.next_page_number }}">&gt;</a> <a class="wh" href="?page={{ workouts.next_page_number }}">&gt;</a>
{% endif %} {% endif %}
</span> </span>
</div>
{% endblock %} {% endblock %}

View File

@@ -2688,10 +2688,20 @@ def workout_flexchart3_view(request,*args,**kwargs):
workstrokesonly = False workstrokesonly = False
# create interactive plot # create interactive plot
script,div,js_resources,css_resources = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1, try:
script,div,js_resources,css_resources = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
yparam2=yparam2, yparam2=yparam2,
promember=promember,plottype=plottype, promember=promember,plottype=plottype,
workstrokesonly=workstrokesonly) workstrokesonly=workstrokesonly)
except ValueError:
script,div = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
yparam2=yparam2,
promember=promember,plottype=plottype,
workstrokesonly=workstrokesonly)
js_resources = ""
css_resources = ""
# script = res[0] # script = res[0]
# div = res[1] # div = res[1]
# js_resources = res[2] # js_resources = res[2]
@@ -3634,10 +3644,10 @@ def workout_upload_view(request,message=""):
f1 = res[0] # file name f1 = res[0] # file name
f2 = res[1] # file name incl media directory f2 = res[1] # file name incl media directory
# new # new
fileformat = get_file_type(f2) fileformat = get_file_type(f2)
if fileformat == 'unknown': if fileformat == 'unknown':
message = "We couldn't recognize the file type" message = "We couldn't recognize the file type"
url = reverse(workout_upload_view, url = reverse(workout_upload_view,
@@ -3724,13 +3734,12 @@ def workout_upload_view(request,message=""):
if row == 0: if row == 0:
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
# auto smoothing # auto smoothing
pace = row.df[' Stroke500mPace (sec/500m)'].values pace = row.df[' Stroke500mPace (sec/500m)'].values
velo = 500./pace velo = 500./pace
f = row.df['TimeStamp (sec)'].diff().mean() f = row.df['TimeStamp (sec)'].diff().mean()
windowsize = 2*(int(10./(f)))+1 windowsize = 2*(int(10./(f)))+1
if not 'originalvelo' in row.df: if not 'originalvelo' in row.df:
row.df['originalvelo'] = velo row.df['originalvelo'] = velo
@@ -3742,9 +3751,9 @@ def workout_upload_view(request,message=""):
velo3 = pd.Series(velo2) velo3 = pd.Series(velo2)
velo3 = velo3.replace([-np.inf,np.inf],np.nan) velo3 = velo3.replace([-np.inf,np.inf],np.nan)
velo3 = velo3.fillna(method='ffill') velo3 = velo3.fillna(method='ffill')
pace2 = 500./abs(velo3)
pace2 = 500./abs(velo3)
row.df[' Stroke500mPace (sec/500m)'] = pace2 row.df[' Stroke500mPace (sec/500m)'] = pace2
row.df = row.df.fillna(0) row.df = row.df.fillna(0)
@@ -3754,7 +3763,6 @@ def workout_upload_view(request,message=""):
os.remove(f2) os.remove(f2)
except: except:
pass pass
# recalculate power data # recalculate power data
if workouttype == 'rower' or workouttype == 'dynamic' or workouttype == 'slides': if workouttype == 'rower' or workouttype == 'dynamic' or workouttype == 'slides':
@@ -3772,12 +3780,11 @@ def workout_upload_view(request,message=""):
averagehr = row.df[' HRCur (bpm)'].mean() averagehr = row.df[' HRCur (bpm)'].mean()
maxhr = row.df[' HRCur (bpm)'].max() maxhr = row.df[' HRCur (bpm)'].max()
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)']
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
minutes = int((totaltime - 3600.*hours)/60.) minutes = int((totaltime - 3600.*hours)/60.)
seconds = int(totaltime - 3600.*hours - 60.*minutes) seconds = int(totaltime - 3600.*hours - 60.*minutes)
@@ -3798,7 +3805,6 @@ def workout_upload_view(request,message=""):
if (len(ws) != 0): if (len(ws) != 0):
message = "Warning: This workout probably already exists in the database" message = "Warning: This workout probably already exists in the database"
w = Workout(user=r,name=t,date=workoutdate, w = Workout(user=r,name=t,date=workoutdate,
workouttype=workouttype, workouttype=workouttype,
duration=duration,distance=totaldist, duration=duration,distance=totaldist,