Private
Public Access
1
0

Merge branch 'release/v11.15'

This commit is contained in:
Sander Roosendaal
2020-02-23 17:07:28 +01:00
7 changed files with 150 additions and 35 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ ratelim==0.1.6
redis==3.2.1 redis==3.2.1
requests==2.21.0 requests==2.21.0
requests-oauthlib==1.2.0 requests-oauthlib==1.2.0
rowingdata==2.6.7 rowingdata==2.7.2
rowingphysics==0.5.0 rowingphysics==0.5.0
rq==0.13.0 rq==0.13.0
rules==2.1 rules==2.1
+4
View File
@@ -731,15 +731,19 @@ class PowerIntervalUpdateForm(forms.Form):
('power','Power'), ('power','Power'),
('pace','Pace'), ('pace','Pace'),
('work','Work per Stroke'), ('work','Work per Stroke'),
('spm','Stroke Rate')
) )
pace = forms.DurationField(required=False,label='Pace (/500m)') pace = forms.DurationField(required=False,label='Pace (/500m)')
power = forms.IntegerField(required=False,label='Power (W)') power = forms.IntegerField(required=False,label='Power (W)')
work = forms.IntegerField(required=False,label='Work per Stroke (J)') work = forms.IntegerField(required=False,label='Work per Stroke (J)')
spm = forms.IntegerField(required=False,label='Stroke Rate')
selector = forms.ChoiceField(choices=selectorchoices, selector = forms.ChoiceField(choices=selectorchoices,
required=True, required=True,
initial='power', initial='power',
label='Use') label='Use')
activeminutesmin = forms.IntegerField(required=False,initial=0,widget=forms.HiddenInput())
activeminutesmax = forms.IntegerField(required=False,initial=0,widget=forms.HiddenInput())
# Form used to update interval stats # Form used to update interval stats
class IntervalUpdateForm(forms.Form): class IntervalUpdateForm(forms.Form):
+38 -11
View File
@@ -7,6 +7,27 @@
{% block scripts %} {% block scripts %}
{% include "monitorjobs.html" %} {% include "monitorjobs.html" %}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
console.log({{ activeminutesmin }}, {{ activeminutesmax}}, 'active range');
$( "#slider-range" ).slider({
range: true,
min: 0,
max: {{ maxminutes }},
values: [ {{ activeminutesmin }}, {{ activeminutesmax }} ],
slide: function( event, ui ) {
$( "#amount" ).val(ui.values[ 0 ] + " min - " + ui.values[ 1 ] + " min " );
$("#id_activeminutesmin").val(ui.values[0]);
$("#id_activeminutesmax").val(ui.values[1]);
}
});
$( "#amount" ).val($( "#slider-range" ).slider( "values", 0 ) +
" min - " + $( "#slider-range" ).slider( "values", 1 ) + " min ");
} );
</script>
{% endblock %} {% endblock %}
{% block main %} {% block main %}
@@ -47,22 +68,28 @@
{{ form.as_table }} {{ form.as_table }}
</table> </table>
{% csrf_token %} {% csrf_token %}
<input class="button green" type="submit" value="Update"> <input class="button" type="submit" value="Update">
</form> </form>
<h1>Intervals by Power/Pace</h1> <h1>Intervals by Power/Pace</h1>
<p>With this form, you can specify a power or pace level. Everything faster/harder than the <p>With this form, you can specify a power or pace level. Everything faster/harder than the
specified pace/power will become a work interval. Everything slower will become a rest specified pace/power will become a work interval. Everything slower will become a rest
interval. interval. Use the slider to limit the active range. Everything outside the active range will
become rest (warming up and cooling down).
</p> </p>
<form ecntype="multipart/form-data" method="post"> <form ecntype="multipart/form-data" method="post">
<div id="slider-range"></div>
<p>
<label for="amount">Active Range:</label>
<input type="text" id="amount" readonly style="border:0; color:#1c75bc; font-weight:bold;">
</p>
<table> <table>
{{ powerupdateform.as_table }} {{ powerupdateform.as_table }}
</table> </table>
{% csrf_token %} {% csrf_token %}
<input class="button green" type="submit" value="Submit"> <input class="button" type="submit" value="Submit">
</form> </form>
</li> </li>
<li class="grid_2"> <li class="grid_2">
@@ -70,7 +97,7 @@
<script async="true" type="text/javascript"> <script async="true" type="text/javascript">
Bokeh.set_log_level("info"); Bokeh.set_log_level("info");
</script> </script>
{{ interactiveplot |safe }} {{ interactiveplot |safe }}
{{ the_div |safe }} {{ the_div |safe }}
@@ -106,7 +133,7 @@
<h1>Detailed Summary Edit</h1> <h1>Detailed Summary Edit</h1>
<p>This is still experimental and there are known bugs. Use at your own risk. Nothing is stored permanently until you hit Save in the Updated Summary section. You can use the restore original button to restore the original values.</p> <p>This is still experimental and there are known bugs. Use at your own risk. Nothing is stored permanently until you hit Save in the Updated Summary section. You can use the restore original button to restore the original values.</p>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id|encode }}/editintervals/" method="post"> <form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id|encode }}/editintervals/" method="post">
<table width=100%> <table width=100%>
<thead> <thead>
<tr> <tr>
<th>#</th><th>Time</th><th>Distance</th><th>Type</th> <th>#</th><th>Time</th><th>Distance</th><th>Type</th>
@@ -131,18 +158,18 @@
</table> </table>
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="nrintervals" value={{ nrintervals }}> <input type="hidden" name="nrintervals" value={{ nrintervals }}>
<input class="button green" type="submit" value="Update"> <input class="button" type="submit" value="Update">
</form> </form>
</li> </li>
<li class="grid_4"> <li class="grid_4">
<h1 id="howto">Interval Shorthand How-To</h1> <h1 id="howto">Interval Shorthand How-To</h1>
<p>This is a quick way to enter the intervals using a special mini-language.</p> <p>This is a quick way to enter the intervals using a special mini-language.</p>
<p>You enter something like <em>8x500m/3min</em>, press "Update" and the site will interpret this for you and update the summary on the right. If you're happy with the result, press the green Save button to update the values. Nothing will be changed permanently until you hit Save.</p> <p>You enter something like <em>8x500m/3min</em>, press "Update" and the site will interpret this for you and update the summary on the right. If you're happy with the result, press the green Save button to update the values. Nothing will be changed permanently until you hit Save.</p>
<p>Special characters are <em>x</em> (times), <em>+</em> and <em>/</em> (denotes a rest interval), as well as <em>(</em> and <em>)</em>. Units are <em>min</em> (minutes), <em>sec</em> (seconds), <em>m</em> (meters) and <em>km</em> (km). </p> <p>Special characters are <em>x</em> (times), <em>+</em> and <em>/</em> (denotes a rest interval), as well as <em>(</em> and <em>)</em>. Units are <em>min</em> (minutes), <em>sec</em> (seconds), <em>m</em> (meters) and <em>km</em> (km). </p>
<p>A typical interval is described as "<b>10min/5min</b>", with the work part before the "<b>/</b>" and the rest part after it. A zero rest can be omitted, so a single 1000m piece could be described either as "<b>1km</b>" or "<b>1000m</b>". The basic units can be combined with "<b>+</b>" and "<b>Nx</b>". You can use parentheses as in the example below.</p> <p>A typical interval is described as "<b>10min/5min</b>", with the work part before the "<b>/</b>" and the rest part after it. A zero rest can be omitted, so a single 1000m piece could be described either as "<b>1km</b>" or "<b>1000m</b>". The basic units can be combined with "<b>+</b>" and "<b>Nx</b>". You can use parentheses as in the example below.</p>
<p>Here are a few examples.</p> <p>Here are a few examples.</p>
<table class="listtable" width=100%> <table class="listtable" width=100%>
<tr> <tr>
+5
View File
@@ -564,6 +564,9 @@ class WorkoutViewTest(TestCase):
'value_pace':'2:23', 'value_pace':'2:23',
'value_power':'200', 'value_power':'200',
'value_work':'400', 'value_work':'400',
'value_spm':'20',
'activeminutesmin':'0',
'activeminutesmax':'60',
'savepowerpaceform':True, 'savepowerpaceform':True,
} }
@@ -582,6 +585,8 @@ class WorkoutViewTest(TestCase):
'power': 200, 'power': 200,
'pace': '2:30', 'pace': '2:30',
'work': 400, 'work': 400,
'activeminutesmin':'0',
'activeminutesmax': '60',
} }
form = PowerIntervalUpdateForm(form_data) form = PowerIntervalUpdateForm(form_data)
+2 -1
View File
@@ -356,7 +356,8 @@ urlpatterns = [
name='workout_video_view_mini'), name='workout_video_view_mini'),
re_path(r'^video/(?P<id>\w.+)/$',views.workout_video_view, re_path(r'^video/(?P<id>\w.+)/$',views.workout_video_view,
name='workout_video_view'), name='workout_video_view'),
re_path(r'^videos/',views.list_videos,name='list_videos'), re_path(r'^videos/$',views.list_videos,name='list_videos'),
re_path(r'^videos/user/(?P<userid>\d+)/$',views.list_videos,name='list_videos'),
re_path(r'^add-video/user/(?P<userid>\d+)/$',views.video_selectworkout,name='video_selectworkout'), re_path(r'^add-video/user/(?P<userid>\d+)/$',views.video_selectworkout,name='video_selectworkout'),
re_path(r'^add-video/',views.video_selectworkout,name='video_selectworkout'), re_path(r'^add-video/',views.video_selectworkout,name='video_selectworkout'),
# re_path(r'^workout/(?P<id>\d+)/$',views.workout_view,name='workout_view'), # re_path(r'^workout/(?P<id>\d+)/$',views.workout_view,name='workout_view'),
+2 -2
View File
@@ -374,8 +374,8 @@ def getrequestrower(request,rowerid=0,userid=0,notpermanent=False):
userid = int(userid) userid = int(userid)
rowerid = int(rowerid) rowerid = int(rowerid)
if userid == 0: #if userid == 0:
userid = request.user.id # userid = request.user.id
if notpermanent == False: if notpermanent == False:
if rowerid == 0 and 'rowerid' in request.session: if rowerid == 0 and 'rowerid' in request.session:
+98 -20
View File
@@ -1762,7 +1762,7 @@ def workouts_view(request,message='',successmessage='',
r = getrequestrower(request,rowerid=rowerid,userid=userid) r = getrequestrower(request,rowerid=rowerid,userid=userid)
# check if access is allowed # check if access is allowed
startdate = datetime.datetime.combine(startdate,datetime.time()) startdate = datetime.datetime.combine(startdate,datetime.time())
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59)) enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
@@ -5045,9 +5045,8 @@ def team_workout_upload_view(request,message="",
workouttype = form.cleaned_data['workouttype'] workouttype = form.cleaned_data['workouttype']
if rowerform.is_valid(): if rowerform.is_valid():
u = rowerform.cleaned_data['user'] u = rowerform.cleaned_data['user']
if can_add_workout_member(request.user,u.rower): r = getrower(u)
r = getrower(u) if not can_add_workout_member(request.user,r):
else:
message = 'Please select a rower' message = 'Please select a rower'
messages.error(request,message) messages.error(request,message)
messages.info(request,successmessage) messages.info(request,successmessage)
@@ -5187,8 +5186,8 @@ def team_workout_upload_view(request,message="",
# A page with all the recent graphs (searchable on workout name) # A page with all the recent graphs (searchable on workout name)
@login_required() @login_required()
def list_videos(request): def list_videos(request,userid=0):
r = getrequestrower(request) r = getrequestrower(request,userid=userid)
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime") workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
query = request.GET.get('q') query = request.GET.get('q')
if query: if query:
@@ -5222,6 +5221,7 @@ def list_videos(request):
{'analyses': g, {'analyses': g,
'searchform':searchform, 'searchform':searchform,
'active':'nav-analysis', 'active':'nav-analysis',
'rower':r,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
}) })
@@ -5600,6 +5600,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
nrintervals = len(idist) nrintervals = len(idist)
activeminutesmax = int(rowdata.duration/60.)
activeminutesmin = 0
maxminutes = activeminutesmax
savebutton = 'nosavebutton' savebutton = 'nosavebutton'
formvalues = {} formvalues = {}
@@ -5609,6 +5612,10 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
normp = row.normp normp = row.normp
normv = row.normv normv = row.normv
normw = row.normw normw = row.normw
try:
normspm = rowdata.df[' Cadence (stokes/min)'].mean()
except KeyError:
normspm = 0
if tss == -1: if tss == -1:
tss,normp = dataprep.workout_rscore(row) tss,normp = dataprep.workout_rscore(row)
@@ -5630,7 +5637,10 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'power': int(normp), 'power': int(normp),
'pace': avpace, 'pace': avpace,
'selector': 'power', 'selector': 'power',
'work': int(normw) 'work': int(normw),
'spm': int(normspm),
'activeminutesmin': 0,
'activeminutesmax': activeminutesmax,
} }
powerorpace = 'power' powerorpace = 'power'
@@ -5665,6 +5675,20 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
value_pace = request.POST['value_pace'] value_pace = request.POST['value_pace']
value_power = request.POST['value_power'] value_power = request.POST['value_power']
value_work = request.POST['value_work'] value_work = request.POST['value_work']
value_spm = request.POST['value_spm']
activeminutesmin = request.POST['activeminutesmin']
activeminutesmax = request.POST['activeminutesmax']
try:
activesecondsmin = 60.*float(activeminutesmin)
activesecondsmax = 60.*float(activeminutesmax)
except ValueError:
activesecondsmin = 0
activeminutesmin = 0
activeminutesmax = maxminutes
activesecondsmax = rowdata.duration
if abs(rowdata.duration-activesecondsmax) < 60.:
activesecondsmax = rowdata.duration
if powerorpace == 'power': if powerorpace == 'power':
try: try:
power = int(value_power) power = int(value_power)
@@ -5683,12 +5707,19 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
work = int(value_work) work = int(value_work)
except ValueError: except ValueError:
work = int(normw) work = int(normw)
elif powerorpace == 'spm':
try:
spm = int(value_spm)
except ValueError:
spm = int(normspm)
if powerorpace == 'power' and power is not None: if powerorpace == 'power' and power is not None:
try: try:
rowdata.updateinterval_metric( rowdata.updateinterval_metric(
' Power (watts)',power,mode='larger', ' Power (watts)',power,mode='larger',
debug=False,smoothwindow=15.) debug=False,smoothwindow=15.,
activewindow=[activesecondsmin,activesecondsmax],
)
except: except:
messages.error(request,'Error updating power') messages.error(request,'Error updating power')
elif powerorpace == 'pace': elif powerorpace == 'pace':
@@ -5696,16 +5727,29 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
velo = 500./pace_secs velo = 500./pace_secs
rowdata.updateinterval_metric( rowdata.updateinterval_metric(
' AverageBoatSpeed (m/s)',velo,mode='larger', ' AverageBoatSpeed (m/s)',velo,mode='larger',
debug=False,smoothwindow=15.) debug=False,smoothwindow=15.,
activewindow=[activesecondsmin,activesecondsmax],
)
except: except:
messages.error(request,'Error updating pace') messages.error(request,'Error updating pace')
elif powerorpace == 'work': elif powerorpace == 'work':
try: try:
rowdata.updateinterval_metric( rowdata.updateinterval_metric(
'driveenergy',work,mode='larger', 'driveenergy',work,mode='larger',
debug=False,smoothwindow=15.) debug=False,smoothwindow=15.,
activewindow=[activesecondsmin,activesecondsmax],
)
except: except:
messages.error(request,'Error updating Work per Stroke') messages.error(request,'Error updating Work per Stroke')
elif powerorpace == 'spm':
try:
print('aap')
rowdata.updateinterval_metric(
' Cadence (stokes/min)',spm,mode='larger',
debug=False,smoothwindow=2.,
activewindow=[activesecondsmin,activesecondsmax],)
except:
messages.error(request,'Error updating SPM')
intervalstats = rowdata.allstats() intervalstats = rowdata.allstats()
itime,idist,itype = rowdata.intervalstats_values() itime,idist,itype = rowdata.intervalstats_values()
@@ -5723,7 +5767,10 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'power': power, 'power': power,
'pace': datetime.timedelta(seconds=int(pace_secs)), 'pace': datetime.timedelta(seconds=int(pace_secs)),
'work': work, 'work': work,
'selector': powerorpace 'selector': powerorpace,
'spm': int(normspm),
'activeminutesmin': activeminutesmin,
'activeminutesmax': activeminutesmax,
} }
form = SummaryStringForm() form = SummaryStringForm()
powerupdateform = PowerIntervalUpdateForm(initial=data) powerupdateform = PowerIntervalUpdateForm(initial=data)
@@ -5768,7 +5815,10 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'power': int(normp), 'power': int(normp),
'pace': avpace, 'pace': avpace,
'selector': 'power', 'selector': 'power',
'work': int(normw) 'work': int(normw),
'spm': int(normspm),
'activeminutesmin': 0,
'activeminutesmax': activeminutesmax,
}) })
savebutton = 'savestringform' savebutton = 'savestringform'
@@ -5781,31 +5831,50 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
power = cd['power'] power = cd['power']
pace = cd['pace'] pace = cd['pace']
work = cd['work'] work = cd['work']
spm = cd['spm']
activeminutesmin = cd['activeminutesmin']
activeminutesmax = cd['activeminutesmax']
activesecondsmin = 60.*activeminutesmin
activesecondsmax = 60.*activeminutesmax
if abs(rowdata.duration-activesecondsmax) < 60.:
activesecondsmax = rowdata.duration
try: try:
pace_secs = pace.seconds+pace.microseconds/1.0e6 pace_secs = pace.seconds+pace.microseconds/1.0e6
except AttributeError: except AttributeError:
pace_secs = 120. pace_secs = 120.
if powerorpace == 'power' and power is not None: if powerorpace == 'power' and power is not None:
try: rowdata.updateinterval_metric(' Power (watts)',power,mode='larger',
rowdata.updateinterval_metric(' Power (watts)',power,mode='larger', debug=False,smoothwindow=15,
debug=False,smoothwindow=15) activewindow=[activesecondsmin,activesecondsmax],
except: )
messages.error(request,'Error updating power')
elif powerorpace == 'pace': elif powerorpace == 'pace':
try: try:
velo = 500./pace_secs velo = 500./pace_secs
rowdata.updateinterval_metric(' AverageBoatSpeed (m/s)',velo,mode='larger', rowdata.updateinterval_metric(' AverageBoatSpeed (m/s)',velo,mode='larger',
debug=False,smoothwindow=15) debug=False,smoothwindow=15,
activewindow=[activesecondsmin,activesecondsmax],
)
except: except:
messages.error(request,'Error updating pace') messages.error(request,'Error updating pace')
elif powerorpace == 'work': elif powerorpace == 'work':
try: try:
rowdata.updateinterval_metric( rowdata.updateinterval_metric(
'driveenergy',work,mode='larger', 'driveenergy',work,mode='larger',
debug=False,smoothwindow=15.) debug=False,smoothwindow=15.,
activewindow=[activesecondsmin,activesecondsmax],)
except: except:
messages.error(request,'Error updating Work per Stroke') messages.error(request,'Error updating Work per Stroke')
elif powerorpace == 'spm':
try:
rowdata.updateinterval_metric(' Cadence (stokes/min)',spm,mode='larger',
debug=False,smoothwindow=2.,
activewindow=[activesecondsmin,activesecondsmax],
)
except:
print('mies')
messages.error(request,'Error updating SPM')
intervalstats = rowdata.allstats() intervalstats = rowdata.allstats()
@@ -5817,6 +5886,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'value_power': power, 'value_power': power,
'value_pace': pace_secs, 'value_pace': pace_secs,
'value_work': work, 'value_work': work,
'value_spm': spm,
'activeminutesmin': activeminutesmin,
'activeminutesmax': activeminutesmax,
} }
powerupdateform = PowerIntervalUpdateForm(initial=cd) powerupdateform = PowerIntervalUpdateForm(initial=cd)
form = SummaryStringForm() form = SummaryStringForm()
@@ -5883,7 +5955,10 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'power': int(normp), 'power': int(normp),
'pace': avpace, 'pace': avpace,
'selector': 'power', 'selector': 'power',
'work': int(normw) 'work': int(normw),
'spm': int(normspm),
'activeminutesmin': 0,
'activeminutesmax': activeminutesmax,
}) })
@@ -5967,6 +6042,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
return render(request, 'summary_edit.html', return render(request, 'summary_edit.html',
{'form':form, {'form':form,
'activeminutesmax':activeminutesmax,
'activeminutesmin':activeminutesmin,
'maxminutes': maxminutes,
'detailform':detailform, 'detailform':detailform,
'powerupdateform':powerupdateform, 'powerupdateform':powerupdateform,
'workout':row, 'workout':row,