Private
Public Access
1
0

adding cp chart to workout menu

This commit is contained in:
Sander Roosendaal
2020-10-15 21:40:58 +02:00
parent 954408ff3d
commit d095f1c21c
5 changed files with 28 additions and 28 deletions

View File

@@ -47,7 +47,7 @@
</div>
</a>
<p>
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.
</p>
</li>
<li class="rounder">
@@ -68,7 +68,7 @@
<img src="/static/img/boxplot.png" alt="Box Chart">
</div>
</a>
<p>
BETA: Box Chart Statistics of stroke metrics over a date range
</p>
@@ -109,26 +109,14 @@
</p>
</li>
<li class="rounder">
<h2>OTW Critical Power</h2>
<a href="/rowers/otw-bests/">
<h2>Critical Power</h2>
<a href="/rowers/user-analysis-select/cp/">
<div class="vignet">
<img src="/static/img/otwcp.png" alt="OTW Critical Power">
<img src="/static/img/otwcp.png" alt="Critical Power">
</div>
</a>
<p>
Analyse power vs piece duration to make predictions. For On-The-Water rowing.
</p>
</li>
<li class="rounder">
<h2>OTE Critical Power</h2>
<a href="/rowers/ote-ranking/">
<div class="vignet">
<img src="/static/img/otecp.png" alt="OTE Critical Power">
</div>
</a>
<p>
Analyse power vs piece duration to make predictions, for erg pieces.
Analyse power vs piece duration to make predictions.
</p>
</li>
<li class="rounder">
@@ -140,7 +128,7 @@
</a>
<p>
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.
</p>
</li>
</ul>

View File

@@ -48,13 +48,8 @@
</a>
</li>
<li id="fitness-otecp">
<a href="/rowers/ote-ranking/">
<i class="fas fa-user-chart fa-fw"></i>&nbsp;CP Chart OTE
</a>
</li>
<li id="fitness-otwcp">
<a href="/rowers/otw-bests/">
<i class="far fa-user-chart fa-fw"></i>&nbsp;CP Chart OTW
<a href="/rowers/user-analysis-select/cp/">
<i class="fas fa-user-chart fa-fw"></i>&nbsp;CP Chart
</a>
</li>
</ul>

View File

@@ -45,6 +45,11 @@
<i class="fas fa-balance-scale fa-fw"></i>&nbsp;Compare
</a>
</li>
<li id="cp">
<a href="/rowers/user-analysis-select/cp/workout/{{ workout.id|encode }}/">
<i class="fas fa-user-chart fa-fw"></i>&nbsp;CP Chart
</a>
</li>
<li id="video-analysis">
<a href="/rowers/workout/{{ workout.id|encode }}/video/">
<i class="fas fa-video-plus fa-fw"></i>&nbsp;Video Analysis

View File

@@ -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<function>\w.*)/user/(?P<userid>\d+)/$',views.analysis_new,name='analysis_new'),
re_path(r'^user-analysis-select/(?P<function>\w.*)/team/(?P<teamid>\d+)/$',views.analysis_new,name='analysis_new'),
re_path(r'^user-analysis-select/(?P<function>\w.*)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.analysis_new,name='analysis_new'),
re_path(r'^user-analysis-select/user/(?P<userid>\d+)/$',views.analysis_new,name='analysis_new'),
re_path(r'^user-analysis-select/team/(?P<teamid>\d+)/$',views.analysis_new,name='analysis_new'),
re_path(r'^user-analysis-select/(?P<function>\w.*)/$',views.analysis_new,name='analysis_new'),

View File

@@ -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: