diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html index 1c52c06a..d4f209c1 100644 --- a/rowers/templates/trainingplan.html +++ b/rowers/templates/trainingplan.html @@ -370,40 +370,40 @@ {% endblock %} {% block scripts %} -{% if thismicro %} +{% if thismicroid %} -{% elif thismeso %} +{% elif thismesoid %} {% endif %} -{% if thismacro %} +{% if thismacroid %} diff --git a/rowers/templatetags/rowerfilters.py b/rowers/templatetags/rowerfilters.py index 66fde5a2..38cfc83d 100644 --- a/rowers/templatetags/rowerfilters.py +++ b/rowers/templatetags/rowerfilters.py @@ -8,7 +8,10 @@ import datetime import re register = template.Library() from rowers.utils import calculate_age -from rowers.models import course_length,WorkoutComment +from rowers.models import ( + course_length,WorkoutComment, + TrainingMacroCycle,TrainingMesoCycle, TrainingMicroCycle + ) from rowers.plannedsessions import ( race_can_register, race_can_submit,race_rower_status ) @@ -373,3 +376,39 @@ def trainingplans(rower): plans = TrainingPlan.objects.filter(rower=rower).order_by("-startdate") return plans + +@register.filter +def mesomacroid(id): + try: + thismeso = TrainingMesoCycle.objects.get(id=id) + except TrainingMesoCycle.DoesNotExist: + return '0' + + theid = thismeso.plan.id + + return str(theid) + +@register.filter +def micromesoid(id): + try: + thismicro = TrainingMicroCycle.objects.get(id=id) + except TrainingMicroCycle.DoesNotExist: + return '0' + + theid = thismicro.plan.id + + return str(theid) + + +@register.filter +def micromacroid(id): + try: + thismicro = TrainingMicroCycle.objects.get(id=id) + except TrainingMicroCycle.DoesNotExist: + return '0' + + theid = thismicro.plan.plan.id + + return str(theid) + + diff --git a/rowers/views.py b/rowers/views.py index 7f654c79..7696a75e 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -16406,23 +16406,6 @@ def rower_trainingplan_view(request, ] - if thismicroid: - thismicro = TrainingMicroCycle.objects.get(id=int(thismicroid)) - else: - if not thismacroid and not thismesoid: - thismicro = get_todays_micro(plan,thedate=startdate) - else: - thismicro = None - - if thismacroid: - thismacro = TrainingMacroCycle.objects.get(id=int(thismacroid)) - else: - thismacro = None - - if thismesoid: - thismeso = TrainingMesoCycle.objects.get(id=int(thismesoid)) - else: - thismeso = None return render(request,'trainingplan.html', @@ -16432,9 +16415,9 @@ def rower_trainingplan_view(request, 'breadcrumbs':breadcrumbs, 'rower':r, 'cycles':cycles, - 'thismicro':thismicro, - 'thismacro':thismacro, - 'thismeso':thismeso, + 'thismicroid':thismicroid, + 'thismacroid':thismacroid, + 'thismesoid':thismesoid, } ) @@ -16483,7 +16466,7 @@ class TrainingMacroCycleUpdate(UpdateView): return reverse(rower_trainingplan_view, kwargs = { 'id':plan.id, - 'thismacro':self.object.id, + 'thismacroid':self.object.id, } )