diff --git a/rowers/templates/planningbuttons.html b/rowers/templates/planningbuttons.html
index 1e9c944a..324efd56 100644
--- a/rowers/templates/planningbuttons.html
+++ b/rowers/templates/planningbuttons.html
@@ -1,14 +1,18 @@
{% load rowerfilters %}
diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html
index cb063a44..d7a9f850 100644
--- a/rowers/templates/trainingplan.html
+++ b/rowers/templates/trainingplan.html
@@ -20,16 +20,6 @@
Training Plan - {{ plan.name }}
This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}.
Edit the plan
-
Click on the plan cycles below to edit their names, start and end dates. The gray "filler"
- cycles are generated, adjusted and deleted automatically to ensure the entire plan
- duration is covered with non-overlapping cycles.
- Once you edit a filler cycle, it become a user-defined cycle, which cannot be deleted
- by the system.
-
A good way to organize the plan is to think of micro cycles as training weeks. Macro cycles
- are typically used to address specific phases of preparation and to indicate the racing
- season and may span several months.
- Meso cycles can be used to group sequences of three to five light, medium and
- hard weeks. It is recommended to work from left to right, starting with the macro cycles.
Macro Cycles
@@ -55,7 +45,12 @@
{% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %}
edit
/
- delete
+
delete
+ /
+
sessions
+
+ {% else %}
+
{% endif %}
@@ -72,8 +67,14 @@
{% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %}
edit
/
- delete
+ delete
+ /
+ sessions
+
+
{% endif %}
+ {% else %}
+
{% endif %}
@@ -91,8 +92,13 @@
edit
/
- delete
+ delete
+ /
+ sessions
+
{% endif %}
+ {% else %}
+
{% endif %}
@@ -102,5 +108,23 @@
{% endfor %}
-
+
+
+
Click on the plan cycles to edit their names, start and end dates. The gray "filler"
+ cycles are generated, adjusted and deleted automatically to ensure the entire plan
+ duration is covered with non-overlapping cycles.
+ Once you edit a filler cycle, it become a user-defined cycle, which cannot be deleted
+ by the system.
+
Filler cycles which have a filler cycle as a parent cannot be edited
+ or deleted. You have to edit the parent cycle first. The reason is
+ that children of filler cycles are not safe. They are deleted when
+ their parent is deleted by the system.
+
Click on "Sessions" in the cycle of your interest to see details
+ of the individual training sessions planned for this period.
+
A good way to organize the plan is to think of micro cycles as training weeks. Macro cycles
+ are typically used to address specific phases of preparation and to indicate the racing
+ season and may span several months.
+ Meso cycles can be used to group sequences of three to five light, medium and
+ hard weeks. It is recommended to work from left to right, starting with the macro cycles.
+
{% endblock %}
diff --git a/rowers/views.py b/rowers/views.py
index 4f5795f5..90acf0b8 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -12483,6 +12483,7 @@ def plannedsession_multiclone_view(
def plannedsession_create_view(request,timeperiod='thisweek',rowerid=0):
r = getrequestrower(request,rowerid=rowerid)
+ startdate,enddate = get_dates_timeperiod(timeperiod)
if request.method == 'POST':
sessioncreateform = PlannedSessionForm(request.POST)
@@ -12539,26 +12540,46 @@ def plannedsession_create_view(request,timeperiod='thisweek',rowerid=0):
fstartdate = arrow.get(request.session['fstartdate']).date()
except KeyError:
fstartdate = timezone.now().date()
+ if fstartdate < startdate:
+ fstartdate = startdate
try:
fenddate = arrow.get(request.session['fenddate']).date()
except KeyError:
fenddate = timezone.now().date()
+ if fenddate > enddate:
+ fenddate = enddate
try:
fprefdate = arrow.get(request.session['fprefdate']).date()
except KeyError:
fprefdate = timezone.now().date()
+ if fprefdate < startdate:
+ fprefdate = startdate
+
+ if fprefdate > enddate:
+ fprefdate = enddate
+
forminitial = {
'startdate':fstartdate,
'enddate':fenddate,
'preferreddate':fprefdate
}
else:
- forminitial = {}
+ preferreddate = startdate
+ if preferreddate < timezone.now().date():
+ preferreddate = timezone.now().date()
+
+ if preferreddate > enddate:
+ preferreddate = enddate
+
+ forminitial = {
+ 'startdate':startdate,
+ 'enddate':enddate,
+ 'preferreddate':preferreddate,
+ }
sessioncreateform = PlannedSessionForm(initial=forminitial)
- startdate,enddate = get_dates_timeperiod(timeperiod)
sps = get_sessions(r,startdate=startdate,enddate=enddate)
return render(request,'plannedsessioncreate.html',
@@ -12943,7 +12964,15 @@ def plannedsessions_view(request,timeperiod='thisweek',rowerid=0):
r = getrequestrower(request,rowerid=rowerid)
startdate,enddate = get_dates_timeperiod(timeperiod)
-
+
+ try:
+ trainingplan = TrainingPlan.objects.filter(
+ startdate__lte = startdate,
+ enddate__gte = enddate)[0]
+ except IndexError:
+ trainingplan = None
+
+
sps = get_sessions(r,startdate=startdate,enddate=enddate)
completeness = {}
@@ -12966,6 +12995,7 @@ def plannedsessions_view(request,timeperiod='thisweek',rowerid=0):
{
'teams':get_my_teams(request.user),
'plannedsessions':sps,
+ 'plan':trainingplan,
'rower':r,
'timeperiod':timeperiod,
'completeness':completeness,
@@ -13120,6 +13150,7 @@ def plannedsessions_manage_view(request,timeperiod='thisweek',rowerid=0,
# Clone an existing planned session
+# need clarity on cloning behavior time shift
@user_passes_test(hasplannedsessions,login_url="/rowers/planmembership/",
redirect_field_name=None)
def plannedsession_clone_view(request,id=0,rowerid=0,
@@ -13146,8 +13177,9 @@ def plannedsession_clone_view(request,id=0,rowerid=0,
ps.startdate = timezone.now().date()
ps.enddate = (timezone.now()+deltadays).date()
+ ps.preferreddate = ps.preferreddate+deltadays
ps.name += ' (copy)'
-
+
ps.save()
for rower in rowers: