From ec75ba1c16e5d23db9a66cecd26a9d5daedb64b4 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Sun, 20 Oct 2019 13:35:03 +0200
Subject: [PATCH] making execution chart accessible
---
rowers/plannedsessions.py | 8 ++++++--
rowers/templates/plannedsessions.html | 5 +++++
rowers/templates/trainingplan.html | 1 +
rowers/views/planviews.py | 9 ++++-----
4 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index a3f8f1a7..05d0bfbc 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -178,7 +178,11 @@ def get_execution_report(rower,startdate,enddate,plan=None):
macros = TrainingMacroCycle.objects.filter(plan=plan).order_by("startdate")
checkscores(rower,macros)
mesos = TrainingMesoCycle.objects.filter(plan__in=macros).order_by("startdate")
- micros = TrainingMicroCycle.objects.filter(plan__in=mesos).order_by("startdate")
+ micros = TrainingMicroCycle.objects.filter(
+ plan__in=mesos,
+ enddate__gte=startdate,
+ startdate__lte=enddate,
+ ).order_by("startdate")
# we've got micros, now get sessions
startdates = []
@@ -203,7 +207,7 @@ def get_execution_report(rower,startdate,enddate,plan=None):
actualscore += minutes
for ps in sps:
ratio, status, cdate = is_session_complete(rower,ps)
- if ps.sessionmode == 'rscore':
+ if ps.sessionmode == 'rScore':
plannedscore += ps.sessionvalue
actualscore += ratio*ps.sessionvalue
else:
diff --git a/rowers/templates/plannedsessions.html b/rowers/templates/plannedsessions.html
index 0bed5c52..0ac86245 100644
--- a/rowers/templates/plannedsessions.html
+++ b/rowers/templates/plannedsessions.html
@@ -122,6 +122,11 @@
Get Calendar File
+
+
+ Actual vs Plan chart
+
diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html
index 2e4d4a01..1a8c8d8e 100644
--- a/rowers/templates/trainingplan.html
+++ b/rowers/templates/trainingplan.html
@@ -27,6 +27,7 @@
{% if plan|mayeditplan:request %}
Edit the plan
{% endif %}
+Plan vs Actual chart
Plan Macro, Meso and Micro Cycles
diff --git a/rowers/views/planviews.py b/rowers/views/planviews.py
index 4809c0fe..15b9abbb 100644
--- a/rowers/views/planviews.py
+++ b/rowers/views/planviews.py
@@ -2336,13 +2336,12 @@ def rower_trainingplan_execution_view(request,
id=0,
userid=0):
- startdate = request.GET.get('startdate')
- enddate = request.GET.get('enddate')
+ startdate,enddate = get_dates_timeperiod(request)
r = getrequestrower(request,userid=userid)
- if int(id):
+ if int(id)>0:
try:
plan = TrainingPlan.objects.get(id=id)
except TrainingPlan.DoesNotExist:
@@ -2352,7 +2351,7 @@ def rower_trainingplan_execution_view(request,
raise PermissionDenied("Access denied")
if not startdate or not enddate:
- if int(id):
+ if int(id)>0:
startdate = plan.startdate
enddate = plan.enddate
else:
@@ -2361,7 +2360,7 @@ def rower_trainingplan_execution_view(request,
startdate,enddate = get_dates_timeperiod(request)
- if int(id):
+ if int(id)>0:
data,message = get_execution_report(r,startdate,enddate,plan=plan)
else:
data,message = get_execution_report(r,startdate,enddate)