From 75ceb89a53cff4949887d6a21401d469f7fb75c6 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 30 Jan 2020 17:33:44 +0100 Subject: [PATCH] a few more views done --- rowers/tests/.~lock.viewnames.csv# | 1 - rowers/tests/viewnames.csv | 32 +++++++++++++++--------------- rowers/urls.py | 2 +- rowers/views/analysisviews.py | 4 ++-- rowers/views/workoutviews.py | 31 ++++++++++------------------- 5 files changed, 30 insertions(+), 40 deletions(-) delete mode 100644 rowers/tests/.~lock.viewnames.csv# diff --git a/rowers/tests/.~lock.viewnames.csv# b/rowers/tests/.~lock.viewnames.csv# deleted file mode 100644 index 02dab132..00000000 --- a/rowers/tests/.~lock.viewnames.csv# +++ /dev/null @@ -1 +0,0 @@ -,sander,sander-pc,25.01.2020 16:35,file:///home/sander/.config/libreoffice/4; \ No newline at end of file diff --git a/rowers/tests/viewnames.csv b/rowers/tests/viewnames.csv index 1611ffa6..d291398d 100644 --- a/rowers/tests/viewnames.csv +++ b/rowers/tests/viewnames.csv @@ -40,22 +40,22 @@ 38,40,rankings_view2,view ranking,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,TRUE,FALSE,TRUE 39,41,otwrankings_view,view ranking,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,TRUE,FALSE,TRUE 40,42,oterankings_view,view ranking,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,TRUE,FALSE,TRUE -41,43,cum_flex,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -42,44,analysis_view_data,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -43,47,cum_flex_data,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -44,48,histo,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -45,49,histo_data,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -46,51,cumstats,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,TRUE,FALSE,FALSE -47,53,graph_show_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -48,54,GraphDelete,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -49,55,get_thumbnails,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE -50,56,otw_use_impeller,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE -51,57,otw_use_gps,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE -52,58,workout_toggle_ranking,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE -53,59,team_workout_upload_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -54,60,workout_upload_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE -55,61,workout_histo_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE -56,62,workout_forcecurve_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE +41,43,cum_flex,flex all chart,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE +42,44,analysis_view_data,redirects to analysis direct,TRUE,302,pro,302,302,pro,302,302,coach,302,302,FALSE,FALSE,FALSE,TRUE +43,47,cum_flex_data,flex all chart data (json),TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE +44,48,histo,histogram view,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,TRUE,FALSE,TRUE +45,49,histo_data,histogram data,TRUE,302,pro,200,302,pro,200,302,coach,200,302,FALSE,FALSE,FALSE,TRUE +46,51,cumstats,cumulative statistics,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,TRUE,FALSE,TRUE +47,53,graph_show_view,show a chart,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE +48,54,GraphDelete,delete a chart,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE +49,55,get_thumbnails,get thumbnails,TRUE,403,basic,200,302,basic,403,403,coach,200,302,FALSE,FALSE,TRUE,TRUE +50,56,otw_use_impeller,switch to impeller data,TRUE,403,basic,302,302,basic,403,302,coach,302,302,FALSE,FALSE,TRUE,TRUE +51,57,otw_use_gps,switch to GPS data,TRUE,403,basic,302,302,basic,403,302,coach,302,302,FALSE,FALSE,TRUE,TRUE +52,58,workout_toggle_ranking,toggle ranking,TRUE,302,basic,302,302,basic,403,302,coach,302,302,FALSE,FALSE,TRUE,TRUE +53,59,team_workout_upload_view,upload workout for team member,TRUE,302,coach,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE +54,60,workout_upload_view,upload a workout,TRUE,302,basic,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE +55,61,workout_histo_view,histogram ,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,FALSE,TRUE,TRUE +56,62,workout_forcecurve_view,force curve,TRUE,302,pro,200,302,pro,403,302,coach,200,302,FALSE,FALSE,TRUE,TRUE 57,63,workout_unsubscribe_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE 58,64,workout_comment_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE 59,65,workout_tcxemail_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,TRUE,FALSE diff --git a/rowers/urls.py b/rowers/urls.py index faf05629..8450a408 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -274,7 +274,7 @@ urlpatterns = [ re_path(r'^flexall/user/(?P\d+)/$',views.cum_flex,name='cum_flex'), re_path(r'^flexall/$',views.cum_flex,name='cum_flex'), re_path(r'^flexalldata/$',views.cum_flex_data,name='cum_flex_data'), - re_path(r'^histo/user/(?P\d+)/$',views.histo,name='histo'), + re_path(r'^histo/user/(?P\d+)/$',views.histo,name='histo'), re_path(r'^histodata/$',views.histo_data,name='histo_data'), # re_path(r'^histo/user/(?P\d+)/(?P\d+-\d+-\d+)/(?P\d+-\d+-\d+)/$',views.histo,name='histo'), re_path(r'^histo/$',views.histo,name='histo'), diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py index 4048b9ac..67392db8 100644 --- a/rowers/views/analysisviews.py +++ b/rowers/views/analysisviews.py @@ -730,7 +730,7 @@ def analysis_view_data(request,userid=0): 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('rower.is_coach',fn=get_user_by_userid,raise_exception=True) -def histo(request,theuser=0, +def histo(request,userid=0, startdate=timezone.now()-datetime.timedelta(days=365), enddate=timezone.now(), deltadays=-1, @@ -744,7 +744,7 @@ def histo(request,theuser=0, 'histoparam':'power' }): - r = getrequestrower(request,userid=theuser) + r = getrequestrower(request,userid=userid) theuser = r.user if 'histoparam' in request.session: diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 2b506203..34819d89 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -386,21 +386,18 @@ def workout_video_create_view(request,id=0): @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. If you are already a Pro user, please log in to access this functionality", redirect_field_name=None) +@permission_required('workout.view_workout',fn=get_workout_by_opaqueid,raise_exception=True) def workout_forcecurve_view(request,id=0,workstrokesonly=False): row = get_workout(id) promember=0 mayedit=0 - if not request.user.is_anonymous: - r = getrower(request.user) - result = request.user.is_authenticated and ispromember(request.user) - if result: - promember=1 - if request.user == row.user.user: - mayedit=1 - if not promember: - return HttpResponseRedirect("/rowers/about/") + r = getrequestrower(request) + promember = 1 + + if r == row.user: + mayedit = 1 if request.method == 'POST': form = ForceCurveOptionsForm(request.POST) @@ -503,21 +500,15 @@ def otw_use_gps(request,id=0): # Show Stroke power histogram for a workout @login_required() +@permission_required('workout.view_workout',fn=get_workout_by_opaqueid,raise_exception=True) def workout_histo_view(request,id=0): w = get_workout(id) + r = getrequestrower(request) + promember = 1 - promember=0 mayedit=0 - if not request.user.is_anonymous: - r = getrower(request.user) - result = request.user.is_authenticated and ispromember(request.user) - if result: - promember=1 - if request.user == w.user.user: - mayedit=1 - - if not promember: - return HttpResponseRedirect("/rowers/about/") + if w.user == r: + mayedit = 1 res = interactive_histoall([w],'power',False) script = res[0]