diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index da035b17..6428378e 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -32,6 +32,34 @@ import courses from rowers.tasks import handle_check_race_course +def get_todays_micro(plan): + thismicro = None + + thismacro = TrainingMacroCycle.objects.filter( + plan=plan, + startdate__lte = date.today(), + enddate__gte = date.today() + ) + + if thismacro: + thismeso = TrainingMesoCycle.objects.filter( + plan=thismacro[0], + startdate__lte = date.today(), + enddate__gte = date.today() + ) + + if thismeso: + thismicro = TrainingMicroCycle.objects.filter( + plan=thismeso[0], + startdate__lte = date.today(), + enddate__gte = date.today() + ) + + if thismicro: + thismicro = thismicro[0] + + return thismicro + # Low Level functions - to be called by higher level methods def add_workouts_plannedsession(ws,ps,r): result = 0 diff --git a/rowers/templates/menu_analytics.html b/rowers/templates/menu_analytics.html index 7c3557c6..ba495712 100644 --- a/rowers/templates/menu_analytics.html +++ b/rowers/templates/menu_analytics.html @@ -71,6 +71,7 @@ {% if user.is_authenticated and user|is_manager %}
+{% if user|team_members %} {% endif %} +{% endif %} diff --git a/rowers/templates/menu_plan.html b/rowers/templates/menu_plan.html index 70cd7191..018fd7d7 100644 --- a/rowers/templates/menu_plan.html +++ b/rowers/templates/menu_plan.html @@ -13,6 +13,13 @@ Manage Plans + {% for plan in rower|trainingplans %} +
+ + + + {% if user.is_authenticated and user|is_manager %}
+{% if user|team_members %} {% endif %} +{% endif %} diff --git a/rowers/templates/menu_profile.html b/rowers/templates/menu_profile.html index 88c78261..8bcdfc7c 100644 --- a/rowers/templates/menu_profile.html +++ b/rowers/templates/menu_profile.html @@ -31,7 +31,7 @@ {% if user.is_authenticated and user|is_manager %}
- +{% if user|team_members %} {% endif %} +{% endif %} diff --git a/rowers/templates/menu_workouts.html b/rowers/templates/menu_workouts.html index 0370e37a..54f1189c 100644 --- a/rowers/templates/menu_workouts.html +++ b/rowers/templates/menu_workouts.html @@ -40,7 +40,7 @@ {% if user.is_authenticated and user|is_manager %}
- +{% if user|team_members %| {% endif %} +{% endif %} diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html index cc17460f..f62ab943 100644 --- a/rowers/templates/trainingplan.html +++ b/rowers/templates/trainingplan.html @@ -1,197 +1,72 @@ -{% extends "base.html" %} +{% extends "newbase.html" %} {% load staticfiles %} {% load rowerfilters %} {% block title %}Rowsandall Training Plans{% endblock %} -{% block scripts %} -{% endblock %} +{% block main %} +
This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. + {% if plan.target %} + The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}. + {% endif %} +
+ -{% block content %} -This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}.
- -| - {{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }}) - | -||||
|---|---|---|---|---|
| - | dist (m) | -t (min) | -rScore | -TRIMP | -
| plan | -{{ macrocycle.0.plandistance }} | -{{ macrocycle.0.plantime }} | -{{ macrocycle.0.planrscore }} | -{{ macrocycle.0.plantrimp }} | -
| actual | -{{ macrocycle.0.actualdistance }} | -{{ macrocycle.0.actualtime }} | -{{ macrocycle.0.actualrscore }} | -{{ macrocycle.0.actualtrimp }} | -
| - | ||||
| - edit - / - delete - / - sessions - | -||||
| - | ||||
| - sessions - | -||||
| - {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) - | -||||
|---|---|---|---|---|
| - | dist (m) | -t (min) | -rScore | -TRIMP | -
| plan | -{{ mesocycle.0.plandistance }} | -{{ mesocycle.0.plantime }} | -{{ mesocycle.0.planrscore }} | -{{ mesocycle.0.plantrimp }} | -
| actual | -{{ mesocycle.0.actualdistance }} | -{{ mesocycle.0.actualtime }} | -{{ mesocycle.0.actualrscore }} | -{{ mesocycle.0.actualtrimp }} | -
| - | ||||
| - edit - / - delete - / - sessions - | -||||
| - | ||||
| - sessions - | -||||
| + Meso {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) + | +|||
|---|---|---|---|
| + edit + / + delete + / + sessions + | +|||
| + Meso {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) + | +||||
|---|---|---|---|---|
| + | dist (m) | +t (min) | +rScore | +TRIMP | +
| plan | +{{ mesocycle.0.plandistance }} | +{{ mesocycle.0.plantime }} | +{{ mesocycle.0.planrscore }} | +{{ mesocycle.0.plantrimp }} | +
| actual | +{{ mesocycle.0.actualdistance }} | +{{ mesocycle.0.actualtime }} | +{{ mesocycle.0.actualrscore }} | +{{ mesocycle.0.actualtrimp }} | +
| + | ||||
| + edit + / + delete + / + sessions + | +||||
| + | ||||
| + sessions + | +||||
| + Micro {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }}) + | +|||
|---|---|---|---|
| + | |||
| + edit + / + delete + / + sessions + | +|||
| + | |||
| + sessions + | +|||
| + Micro {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }}) + | +||||
|---|---|---|---|---|
| + | dist (m) | +t (min) | +rScore | +TRIMP | +
| plan | +{{ microcycle.plandistance }} | +{{ microcycle.plantime }} | +{{ microcycle.planrscore }} | +{{ microcycle.plantrimp }} | +
| actual | +{{ microcycle.actualdistance }} | +{{ microcycle.actualtime }} | +{{ microcycle.actualrscore }} | +{{ microcycle.actualtrimp }} | +
| + | ||||
| + edit + / + delete + / + sessions + | +||||
| + | ||||
| + sessions + | +||||
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.
-Click on the cycle to fold out its contents.
+ +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 %} + +{% block scripts %} +{% if thismicro %} + + +{% elif thismeso %} + + +{% endif %} +{% if thismacro %} + + +{% endif %} +{% endblock %} + +{% block sidebar %} +{% include 'menu_plan.html' %} {% endblock %} diff --git a/rowers/templatetags/rowerfilters.py b/rowers/templatetags/rowerfilters.py index 30a23bc7..223736a2 100644 --- a/rowers/templatetags/rowerfilters.py +++ b/rowers/templatetags/rowerfilters.py @@ -185,7 +185,7 @@ def get_field_id(id,s,form): field_name = s+str(id) return form.__getitem__(field_name) -from rowers.models import Rower,Team +from rowers.models import Rower,Team,TrainingPlan,TrainingTarget from rowers.views import ispromember @register.filter @@ -350,3 +350,23 @@ def userurl(path,member): replaced = path+userstring return replaced + +@register.filter +def timeurl(path,timestring): + pattern = re.compile('\?when=w.*') + timeurl = '?when=%s' % timestring + replaced = '' + + if pattern.search(path) is not None: + replaced = pattern.sub(timeurl,path) + + if not replaced: + replaced = path+timeurl + + return replaced + +@register.filter +def trainingplans(rower): + plans = TrainingPlan.objects.filter(rower=rower).order_by("-startdate") + + return plans diff --git a/rowers/urls.py b/rowers/urls.py index 34607d96..510e2008 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -413,13 +413,20 @@ urlpatterns = [ # url(r'^workout/compare/(?P