some more logic around fillers and start dates
This commit is contained in:
@@ -1095,7 +1095,20 @@ def createmacrofillers(plan):
|
|||||||
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
cycles = cycles[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):
|
def createmesofillers(plan):
|
||||||
fillers = TrainingMesoCycle.objects.filter(
|
fillers = TrainingMesoCycle.objects.filter(
|
||||||
plan = plan, type = 'filler'
|
plan = plan, type = 'filler'
|
||||||
@@ -1131,6 +1144,20 @@ def createmesofillers(plan):
|
|||||||
macr.save()
|
macr.save()
|
||||||
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
cycles = cycles[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):
|
def createmicrofillers(plan):
|
||||||
@@ -1169,6 +1196,20 @@ def createmicrofillers(plan):
|
|||||||
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
cycles = cycles[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):
|
def microcyclecheckdates(plan):
|
||||||
cycles = TrainingMicroCycle.objects.filter(
|
cycles = TrainingMicroCycle.objects.filter(
|
||||||
plan=plan
|
plan=plan
|
||||||
@@ -1203,6 +1244,21 @@ def mesocyclecheckdates(plan):
|
|||||||
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
cycles = cycles[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):
|
def macrocyclecheckdates(plan):
|
||||||
cycles = TrainingMacroCycle.objects.filter(
|
cycles = TrainingMacroCycle.objects.filter(
|
||||||
plan=plan
|
plan=plan
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
are typically used to address specific phases of preparation and to indicate the racing
|
are typically used to address specific phases of preparation and to indicate the racing
|
||||||
season and may span several months.
|
season and may span several months.
|
||||||
Meso cycles can be used to group sequences of three to five light, medium and
|
Meso cycles can be used to group sequences of three to five light, medium and
|
||||||
hard weeks. </p>
|
hard weeks. It is recommended to work from left to right, starting with the macro cycles.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 alpha">
|
||||||
<h2>Macro Cycles</h2>
|
<h2>Macro Cycles</h2>
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
|
{% now "Y-m-d" as todays_date %}
|
||||||
{% for key,macrocycle in cycles.items %}
|
{% for key,macrocycle in cycles.items %}
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
{% if macrocycle.0.type == 'filler' %}
|
{% if macrocycle.0.type == 'filler' %}
|
||||||
@@ -51,9 +52,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="padded">
|
<div class="padded">
|
||||||
<h3>{{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})</h3>
|
<h3>{{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})</h3>
|
||||||
|
{% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %}
|
||||||
<p><a href="/rowers/macrocycle/{{ macrocycle.0.id }}">edit</a>
|
<p><a href="/rowers/macrocycle/{{ macrocycle.0.id }}">edit</a>
|
||||||
/
|
/
|
||||||
<a href="/rowers/deletemacrocycle/{{ macrocycle.0.id }}">delete</a></p>
|
<a href="/rowers/deletemacrocycle/{{ macrocycle.0.id }}">delete</a></p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_8 alpha">
|
<div class="grid_8 alpha">
|
||||||
@@ -65,9 +68,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="padded">
|
<div class="padded">
|
||||||
<h3>{{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})</h3>
|
<h3>{{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})</h3>
|
||||||
|
{% if mesocycle.0.plan.type == 'userdefined' %}
|
||||||
|
{% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %}
|
||||||
<p><a href="/rowers/mesocycle/{{ mesocycle.0.id }}">edit</a>
|
<p><a href="/rowers/mesocycle/{{ mesocycle.0.id }}">edit</a>
|
||||||
/
|
/
|
||||||
<a href="/rowers/deletemesocycle/{{ mesocycle.0.id }}">delete</a></p>
|
<a href="/rowers/deletemesocycle/{{ mesocycle.0.id }}">delete</a></p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 omega">
|
<div class="grid_4 omega">
|
||||||
@@ -79,10 +86,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="padded">
|
<div class="padded">
|
||||||
<h3>{{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})</h3>
|
<h3>{{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})</h3>
|
||||||
|
{% if microcycle.plan.type == 'userdefined' %}
|
||||||
|
{% if todays_date <= microcycle.enddate|date:"Y-m-d" %}
|
||||||
<p>
|
<p>
|
||||||
<a href="/rowers/microcycle/{{ microcycle.id }}">edit</a>
|
<a href="/rowers/microcycle/{{ microcycle.id }}">edit</a>
|
||||||
/
|
/
|
||||||
<a href="/rowers/deletemicrocycle/{{ microcycle.id }}">delete</a></p>
|
<a href="/rowers/deletemicrocycle/{{ microcycle.id }}">delete</a></p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -100,8 +100,9 @@
|
|||||||
<td> {{ plan.startdate }} </td>
|
<td> {{ plan.startdate }} </td>
|
||||||
<td> {{ plan.enddate }}</td>
|
<td> {{ plan.enddate }}</td>
|
||||||
<td><a href="/rowers/plan/{{ plan.id }}">{{ plan.name }}</a></td>
|
<td><a href="/rowers/plan/{{ plan.id }}">{{ plan.name }}</a></td>
|
||||||
<td> <a href="/rowers/editplan/{{ plan.id }}">Edit</a>
|
<td> <a href="/rowers/editplan/{{ plan.id }}">Edit</a></td>
|
||||||
<td> <a href="/rowers/deleteplan/{{ plan.id }}">Delete</a>
|
<td> <a href="/rowers/plan/{{ plan.id }}">Plan</a></td>
|
||||||
|
<td> <a href="/rowers/deleteplan/{{ plan.id }}">Delete</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -275,3 +275,10 @@ def future_registered(race,r):
|
|||||||
is_complete, has_registered = race_rower_status(r,race)
|
is_complete, has_registered = race_rower_status(r,race)
|
||||||
is_open = race.evaluation_closure > timezone.now()
|
is_open = race.evaluation_closure > timezone.now()
|
||||||
return has_registered and not is_complete and is_open
|
return has_registered and not is_complete and is_open
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_past_due(self):
|
||||||
|
return datetime.date.today() > self.date
|
||||||
|
@property
|
||||||
|
def is_not_past_due(self):
|
||||||
|
return datetime.date.today() <= self.date
|
||||||
|
|||||||
Reference in New Issue
Block a user