Private
Public Access
1
0

Merge branch 'release/v16.4.27'

This commit is contained in:
Sander Roosendaal
2021-08-26 08:36:41 +02:00
5 changed files with 60 additions and 12 deletions

View File

@@ -2153,8 +2153,12 @@ def interactive_histoall(theworkouts,histoparam,includereststrokes,
# throw out nans # throw out nans
histopwr = histopwr[~np.isinf(histopwr)] histopwr = histopwr[~np.isinf(histopwr)]
histopwr = histopwr[histopwr > yaxminima[histoparam]] if histoparam == 'catch':
histopwr = histopwr[histopwr < yaxmaxima[histoparam]] histopwr = histopwr[histopwr < yaxminima[histoparam]]
histopwr = histopwr[histopwr > yaxmaxima[histoparam]]
else:
histopwr = histopwr[histopwr > yaxminima[histoparam]]
histopwr = histopwr[histopwr < yaxmaxima[histoparam]]
plot = Figure(tools=TOOLS,plot_width=900, plot = Figure(tools=TOOLS,plot_width=900,
toolbar_sticky=False, toolbar_sticky=False,

View File

@@ -307,9 +307,10 @@ class Command(BaseCommand):
message.delete() message.delete()
# Strava # Strava
#rowers = Rower.objects.filter(strava_auto_import=True) rowers = Rower.objects.filter(strava_auto_import=True)
#for r in rowers: for r in rowers:
# stravastuff.get_strava_workouts(r) if user_is_not_basic(r.user):
stravastuff.get_strava_workouts(r)
self.stdout.write(self.style.SUCCESS( self.stdout.write(self.style.SUCCESS(
'Successfully processed email attachments')) 'Successfully processed email attachments'))

View File

@@ -18,6 +18,10 @@
</li> </li>
<li class="grid_4"> <li class="grid_4">
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
<input name='workouts' type="submit" value="Import selected workouts">
<a href="/rowers/workout/stravaimport/?selectallnew=true">Select All New</a>
<table width="70%" class="listtable"> <table width="70%" class="listtable">
<thead> <thead>
<tr> <tr>
@@ -34,7 +38,12 @@
{% for workout in workouts %} {% for workout in workouts %}
<tr> <tr>
<td> <td>
<a href="/rowers/workout/stravaimport/{{ workout|lookup:'id' }}/async/">Import</a></td> {% if workout|lookup:'new' == 'NEW' and checknew == 'true' %}
<input checked type="checkbox" value={{ workout|lookup:'id' }} name="workoutid">
{% else %}
<input type="checkbox" value={{ workout|lookup:'id' }} name="workoutid">
{% endif %}
</td>
<td>{{ workout|lookup:'name' }}</td> <td>{{ workout|lookup:'name' }}</td>
<td>{{ workout|lookup:'starttime' }}</td> <td>{{ workout|lookup:'starttime' }}</td>
<td>{{ workout|lookup:'duration' }} </td> <td>{{ workout|lookup:'duration' }} </td>
@@ -46,6 +55,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</form>
</li> </li>
</ul> </ul>
{% else %} {% else %}

View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
from rowers.views.statements import * from rowers.views.statements import *
from rowers.plannedsessions import get_dates_timeperiod from rowers.plannedsessions import get_dates_timeperiod
from rowers.tasks import fetch_strava_workout
import numpy import numpy
@@ -923,6 +924,7 @@ def workout_rp3import_view(request,userid=0):
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True) @permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
@permission_required('rower.is_not_freecoach',fn=get_user_by_userid, raise_exception=True) @permission_required('rower.is_not_freecoach',fn=get_user_by_userid, raise_exception=True)
def workout_stravaimport_view(request,message="",userid=0): def workout_stravaimport_view(request,message="",userid=0):
r = getrequestrower(request,userid=userid) r = getrequestrower(request,userid=userid)
if r.user != request.user: if r.user != request.user:
messages.error(request,'You can only access your own workouts on the NK Logbook, not those of your athletes') messages.error(request,'You can only access your own workouts on the NK Logbook, not those of your athletes')
@@ -939,6 +941,7 @@ def workout_stravaimport_view(request,message="",userid=0):
res = stravastuff.get_strava_workout_list(request.user) res = stravastuff.get_strava_workout_list(request.user)
if (res.status_code != 200): # pragma: no cover if (res.status_code != 200): # pragma: no cover
if (res.status_code == 401): if (res.status_code == 401):
r = getrower(request.user) r = getrower(request.user)
@@ -952,6 +955,7 @@ def workout_stravaimport_view(request,message="",userid=0):
else: else:
workouts = [] workouts = []
r = getrower(request.user) r = getrower(request.user)
rower = r
stravaids = [int(item['id']) for item in res.json()] stravaids = [int(item['id']) for item in res.json()]
stravadata = [{ stravadata = [{
'id':int(item['id']), 'id':int(item['id']),
@@ -995,8 +999,34 @@ def workout_stravaimport_view(request,message="",userid=0):
r = item['type'] r = item['type']
keys = ['id','distance','duration','starttime','type','name','new'] keys = ['id','distance','duration','starttime','type','name','new']
values = [i,d,ttot,s,r,n,nnn] values = [i,d,ttot,s,r,n,nnn]
res = dict(zip(keys,values)) res2 = dict(zip(keys,values))
workouts.append(res) workouts.append(res2)
if request.method == "POST":
try:
tdict = dict(request.POST.lists())
ids = tdict['workoutid']
stravaids = [int(id) for id in ids]
alldata = {}
for item in res.json():
alldata[item['id']] = item
for stravaid in stravaids:
csvfilename = 'media/{code}_{stravaid}.csv'.format(code=uuid4().hex[:16],stravaid=stravaid)
result = myqueue(
queue,
fetch_strava_workout,
rower.stravatoken,
stravastuff.oauth_data,
stravaid,
csvfilename,
rower.user.id
)
# done, redirect to workouts list
messages.info(request,'Your Strava workouts will be imported in the background. It may take a few minutes before it appears.'.format(stravaid=stravaid))
url = reverse('workouts_view')
return HttpResponseRedirect(url)
except KeyError:
pass
breadcrumbs = [ breadcrumbs = [
{ {
@@ -1009,15 +1039,15 @@ def workout_stravaimport_view(request,message="",userid=0):
}, },
] ]
checknew = request.GET.get('selectallnew',False)
r = getrower(request.user)
return render(request,'strava_list_import.html', return render(request,'strava_list_import.html',
{'workouts':workouts, {'workouts':workouts,
'rower':r, 'rower':rower,
'active':'nav-workouts', 'active':'nav-workouts',
'breadcrumbs':breadcrumbs, 'breadcrumbs':breadcrumbs,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'checknew':checknew,
}) })
return HttpResponse(res) # pragma: no cover return HttpResponse(res) # pragma: no cover

View File

@@ -3502,7 +3502,10 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
hrdrift = ((pwr1/hr1)-(pwr2/hr2))/(pwr1/hr1) hrdrift = ((pwr1/hr1)-(pwr2/hr2))/(pwr1/hr1)
hrdrift *= 100. hrdrift *= 100.
if not np.isnan(hrdrift): if not np.isnan(hrdrift):
hrdrift = int(100*hrdrift)/100. try:
hrdrift = int(100*hrdrift)/100.
except:
hrdrift = 0
otherstats['hrdrift'] = { otherstats['hrdrift'] = {
'verbose_name': 'Heart Rate Drift', 'verbose_name': 'Heart Rate Drift',
'value': hrdrift, 'value': hrdrift,