From d095f1c21c93cc5be1e5d55ec65108db60c62277 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 15 Oct 2020 21:40:58 +0200 Subject: [PATCH] adding cp chart to workout menu --- rowers/templates/analysis.html | 26 +++++++------------------- rowers/templates/menu_analytics.html | 9 ++------- rowers/templates/menu_workout.html | 5 +++++ rowers/urls.py | 1 + rowers/views/analysisviews.py | 15 +++++++++++++-- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/rowers/templates/analysis.html b/rowers/templates/analysis.html index beed03bb..e70e4a42 100644 --- a/rowers/templates/analysis.html +++ b/rowers/templates/analysis.html @@ -47,7 +47,7 @@

- Plot a histogram chart of one metric for all your strokes over a date range. + Plot a histogram chart of one metric for all your strokes over a date range.

  • @@ -68,7 +68,7 @@ Box Chart - +

    BETA: Box Chart Statistics of stroke metrics over a date range

    @@ -109,26 +109,14 @@

  • -

    OTW Critical Power

    - +

    Critical Power

    +
    - OTW Critical Power + Critical Power

    - Analyse power vs piece duration to make predictions. For On-The-Water rowing. -

    -
  • -
  • -

    OTE Critical Power

    - -
    - OTE Critical Power -
    -
    - -

    - Analyse power vs piece duration to make predictions, for erg pieces. + Analyse power vs piece duration to make predictions.

  • @@ -140,7 +128,7 @@

    - Need to monitor a metric? Set up automatic alerting and see the reports for your workouts. + Need to monitor a metric? Set up automatic alerting and see the reports for your workouts.

  • diff --git a/rowers/templates/menu_analytics.html b/rowers/templates/menu_analytics.html index df8a23c6..7d4d5c2d 100644 --- a/rowers/templates/menu_analytics.html +++ b/rowers/templates/menu_analytics.html @@ -48,13 +48,8 @@
  • - -  CP Chart OTE - -
  • -
  • - -  CP Chart OTW + +  CP Chart
  • diff --git a/rowers/templates/menu_workout.html b/rowers/templates/menu_workout.html index a4b98796..a1d3eab9 100644 --- a/rowers/templates/menu_workout.html +++ b/rowers/templates/menu_workout.html @@ -45,6 +45,11 @@  Compare +
  • + +  CP Chart + +
  •  Video Analysis diff --git a/rowers/urls.py b/rowers/urls.py index 78dc9f48..f812ea13 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -326,6 +326,7 @@ urlpatterns = [ re_path(r'^user-boxplot-select/$',views.user_boxplot_select,name='user_boxplot_select'), re_path(r'^user-analysis-select/(?P\w.*)/user/(?P\d+)/$',views.analysis_new,name='analysis_new'), re_path(r'^user-analysis-select/(?P\w.*)/team/(?P\d+)/$',views.analysis_new,name='analysis_new'), + re_path(r'^user-analysis-select/(?P\w.*)/workout/(?P\b[0-9A-Fa-f]+\b)/$',views.analysis_new,name='analysis_new'), re_path(r'^user-analysis-select/user/(?P\d+)/$',views.analysis_new,name='analysis_new'), re_path(r'^user-analysis-select/team/(?P\d+)/$',views.analysis_new,name='analysis_new'), re_path(r'^user-analysis-select/(?P\w.*)/$',views.analysis_new,name='analysis_new'), diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py index d0ea82e2..a1a31e02 100644 --- a/rowers/views/analysisviews.py +++ b/rowers/views/analysisviews.py @@ -34,11 +34,19 @@ defaultoptions = { 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 analysis_new(request,userid=0,function='boxplot',teamid=0): +def analysis_new(request,userid=0,function='boxplot',teamid=0,id=0): r = getrequestrower(request, userid=userid) user = r.user userid = user.id + if id: + firstworkout = get_workout(id) + if not is_workout_team(request.user,firstworkout): + raise PermissionDenied("You are not allowed to use this workout") + firstworkoutquery = Workout.objects.filter(id=encoder.decode_hex(id)) + else: + firtworkout = None + try: theteam = Team.objects.get(id=teamid) except Team.DoesNotExist: @@ -188,7 +196,8 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0): startdatetime__lte=enddate, workouttype__in=modalities, ) - + if firstworkout: + workouts = firstworkoutquery | workouts workouts = workouts.order_by( "-date", "-starttime" ).exclude(boattype__in=negtypes) @@ -212,6 +221,8 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0): if request.method != 'POST': form = WorkoutMultipleCompareForm() + if id: + form.fields["workouts"].initial = [firstworkout] chartform = AnalysisChoiceForm(initial={'function':function}) selectedworkouts = Workout.objects.none() else: