Private
Public Access
1
0

Merge branch 'release/v18.9.3'

This commit is contained in:
Sander Roosendaal
2022-12-24 13:10:03 +01:00
3 changed files with 57 additions and 0 deletions

View File

@@ -163,6 +163,9 @@ $( function() {
</p>
</div>
</form>
<p>
<a href="/rowers/workout/{{ workout.id|encode }}/instroke/interactive/{{ metric }}/{{ spm_min }}/{{ spm_max }}/{{ activeminutesmin }}/{{ activeminutesmax }}/">Download data</a>
</p>
</li>
<li class="grid_4">
<div id="id_chart" class="flexplot">

View File

@@ -260,6 +260,8 @@ urlpatterns = [
views.instroke_chart_interactive, name='instroke_chart_interactive'),
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/instroke/interactive/(?P<analysis>\d+)/user/(?P<userid>\d+)/$',
views.instroke_chart_interactive, name='instroke_chart_interactive'),
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/instroke/interactive/(?P<metric>[A-Za-z_\ %20]+)/(?P<spm_min>[0-9]+\.?[0-9]*)/(?P<spm_max>[0-9]+\.?[0-9]*)/(?P<activeminutesmin>[0-9]+\.?[0-9]*)/(?P<activeminutesmax>[0-9]+\.?[0-9]*)/$',
views.instroke_data, name='instroke_data'),
re_path(r'^exportallworkouts/?/$', views.workouts_summaries_email_view,
name='workouts_summaries_email_view'),
path('failedjobs/', views.failed_queue_view, name='failed_queue_view'),

View File

@@ -3134,6 +3134,57 @@ def instroke_chart(request, id=0, metric=''): # pragma: no cover
return HttpResponseRedirect(url)
@user_passes_test(ispromember, login_url="/rowers/paidplans",
message="This functionality requires a Pro plan or higher."
" If you are already a Pro user, please log in to access this functionality",
redirect_field_name=None)
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
def instroke_data(request, metric='', spm_min=15, spm_max=45, activeminutesmin=0, activeminutesmax=0, id=0, ):
r = getrequestrower(request, userid=0)
w = get_workoutuser(id, request)
rowdata = rrdata(csvfile=w.csvfilename)
instrokemetrics = rowdata.get_instroke_columns()
if not metric:
metric = instrokemetrics[0]
if activeminutesmax == 0:
activeminutesmax = rowdata.duration/60.
try:
spm_min = float(spm_min)
except ValueError:
pass
try:
spm_max = float(spm_max)
except ValueError:
pass
try:
activeminutesmin = float(activeminutesmin)
except ValueError:
pass
try:
activeminutesmax = float(activeminutesmax)
except ValueError:
pass
data = rowdata.get_instroke_data(metric, spm_min=spm_min,
spm_max=spm_max,
activeminutesmin=activeminutesmin,
activeminutesmax=activeminutesmax,
)
filename = str(uuid4())+'.csv'
data.to_csv(filename)
with open(filename, 'r') as f:
response = HttpResponse(f)
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
response['Content-Type'] = 'application/octet-stream'
os.remove(filename)
return response
@user_passes_test(ispromember, login_url="/rowers/paidplans",
message="This functionality requires a Pro plan or higher."
" If you are already a Pro user, please log in to access this functionality",
@@ -3398,6 +3449,7 @@ def instroke_chart_interactive(request, id=0, analysis=0, userid=0):
'teams': get_my_teams(request.user),
'instrokemetrics': instrokemetrics,
'form':form,
'metric': metric,
'the_script': script,
'the_div': div,
'spm_min': spm_min,