diff --git a/rowers/models.py b/rowers/models.py index 924c4a4a..00fd6da7 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1095,7 +1095,20 @@ def createmacrofillers(plan): thedate = cycles[0].startdate-datetime.timedelta(days=1) cycles = cycles[1:] + cycles = TrainingMacroCycle.objects.filter( + plan = plan + ).order_by("startdate") + if cycles[0].startdate > plan.startdate: + macr = TrainingMacroCycle( + plan=plan, + startdate = plan.startdate, + enddate = cycles[0].startdate-datetime.timedelta(days=1), + type='filler', + name='Filler' + ) + macr.save() + def createmesofillers(plan): fillers = TrainingMesoCycle.objects.filter( plan = plan, type = 'filler' @@ -1131,6 +1144,20 @@ def createmesofillers(plan): macr.save() thedate = cycles[0].startdate-datetime.timedelta(days=1) cycles = cycles[1:] + + cycles = TrainingMesoCycle.objects.filter( + plan = plan + ).order_by("startdate") + + if cycles[0].startdate > plan.startdate: + macr = TrainingMesoCycle( + plan=plan, + startdate = plan.startdate, + enddate = cycles[0].startdate-datetime.timedelta(days=1), + type='filler', + name='Filler' + ) + macr.save() def createmicrofillers(plan): @@ -1169,6 +1196,20 @@ def createmicrofillers(plan): thedate = cycles[0].startdate-datetime.timedelta(days=1) cycles = cycles[1:] + cycles = TrainingMicroCycle.objects.filter( + plan = plan + ).order_by("startdate") + + if cycles[0].startdate > plan.startdate: + macr = TrainingMicroCycle( + plan=plan, + startdate = plan.startdate, + enddate = cycles[0].startdate-datetime.timedelta(days=1), + type='filler', + name='Filler' + ) + macr.save() + def microcyclecheckdates(plan): cycles = TrainingMicroCycle.objects.filter( plan=plan @@ -1203,6 +1244,21 @@ def mesocyclecheckdates(plan): thedate = cycles[0].startdate-datetime.timedelta(days=1) cycles = cycles[1:] + cycles = TrainingMesoCycle.objects.filter( + plan=plan + ).order_by("startdate") + + thedate = plan.startdate + while cycles: + if cycles[0].startdate < thedate: + cycles[0].startdate = thedate + cycles[0].save() + try: + thedate = cycles[1].startdate-datetime.timedelta(days=1) + except IndexError: + pass + cycles = cycles[1:] + def macrocyclecheckdates(plan): cycles = TrainingMacroCycle.objects.filter( plan=plan diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html index 62dbb83c..cb063a44 100644 --- a/rowers/templates/trainingplan.html +++ b/rowers/templates/trainingplan.html @@ -29,7 +29,7 @@ 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.
+ hard weeks. It is recommended to work from left to right, starting with the macro cycles.