Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2018-10-12 15:40:49 +02:00
parent f72335c49d
commit 3cfc620906
11 changed files with 700 additions and 298 deletions

View File

@@ -32,6 +32,34 @@ import courses
from rowers.tasks import handle_check_race_course 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 # Low Level functions - to be called by higher level methods
def add_workouts_plannedsession(ws,ps,r): def add_workouts_plannedsession(ws,ps,r):
result = 0 result = 0

View File

@@ -71,6 +71,7 @@
{% if user.is_authenticated and user|is_manager %} {% if user.is_authenticated and user|is_manager %}
<p>&nbsp;</p> <p>&nbsp;</p>
{% if user|team_members %}
<ul class="cd-accordion-menu animated"> <ul class="cd-accordion-menu animated">
<li class="has-children" id="athletes"> <li class="has-children" id="athletes">
<input type="checkbox" name="athlete-selector" id="athlete-selector"> <input type="checkbox" name="athlete-selector" id="athlete-selector">
@@ -91,3 +92,4 @@
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endif %}

View File

@@ -13,6 +13,13 @@
<i class="fas fa-bullseye-pointer"></i>&nbsp;Manage Plans <i class="fas fa-bullseye-pointer"></i>&nbsp;Manage Plans
</a> </a>
</li> </li>
{% for plan in rower|trainingplans %}
<li id="plan-{{ plan.id }}">
<a href="/rowers/plan/{{ plan.id }}">
<i class="fal fa-calendar-alt fa-fw"></i>&nbsp;{{ plan.name }}
</a>
</li>
{% endfor %}
</ul> </ul>
</li> </li>
<li class="has-children" id="sessions"> <li class="has-children" id="sessions">
@@ -63,9 +70,70 @@
</li> </li>
</ul><!-- cd-accordion-menu --> </ul><!-- cd-accordion-menu -->
<p>&nbsp;</p>
<ul class="cd-accordion-menu animated">
<li class="has-children" id="cycles">
<input type="checkbox" name="cycle-selector" id="cycle-selector">
<label for="cycle-selector"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;Select Time Period</label>
<ul>
<li class="has-children" id="cycles-this">
<input type="checkbox" name="cycle-this" id="cycle-this">
<label for="cycle-this">This</label>
<ul>
<li>
<a href = {{ request.path|timeurl:"thisweek" }}>
Week
</a>
</li>
<li>
<a href = {{ request.path|timeurl:"thismonth" }}>
Month
</a>
</li>
</ul>
</li>
<li class="has-children" id="cycles-next">
<input type="checkbox" name="cycle-next" id="cycle-next">
<label for="cycle-next">Next</label>
<ul>
<li>
<a href = {{ request.path|timeurl:"nextweek" }}>
Week
</a>
</li>
<li>
<a href = {{ request.path|timeurl:"nextmonth" }}>
Month
</a>
</li>
</ul>
</li>
<li class="has-children" id="cycles-Last">
<input type="checkbox" name="cycle-Last" id="cycle-Last">
<label for="cycle-Last">Last</label>
<ul>
<li>
<a href = {{ request.path|timeurl:"lastweek" }}>
Week
</a>
</li>
<li>
<a href = {{ request.path|timeurl:"lastmonth" }}>
Month
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
{% if user.is_authenticated and user|is_manager %} {% if user.is_authenticated and user|is_manager %}
<p>&nbsp;</p> <p>&nbsp;</p>
{% if user|team_members %}
<ul class="cd-accordion-menu animated"> <ul class="cd-accordion-menu animated">
<li class="has-children" id="athletes"> <li class="has-children" id="athletes">
<input type="checkbox" name="athlete-selector" id="athlete-selector"> <input type="checkbox" name="athlete-selector" id="athlete-selector">
@@ -86,3 +154,4 @@
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endif %}

View File

@@ -31,7 +31,7 @@
{% if user.is_authenticated and user|is_manager %} {% if user.is_authenticated and user|is_manager %}
<p>&nbsp;</p> <p>&nbsp;</p>
{% if user|team_members %}
<ul class="cd-accordion-menu animated"> <ul class="cd-accordion-menu animated">
<li class="has-children" id="athletes"> <li class="has-children" id="athletes">
<input type="checkbox" name="athlete-selector" id="athlete-selector"> <input type="checkbox" name="athlete-selector" id="athlete-selector">
@@ -52,3 +52,4 @@
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endif %}

View File

@@ -40,7 +40,7 @@
{% if user.is_authenticated and user|is_manager %} {% if user.is_authenticated and user|is_manager %}
<p>&nbsp;</p> <p>&nbsp;</p>
{% if user|team_members %|
<ul class="cd-accordion-menu animated"> <ul class="cd-accordion-menu animated">
<li class="has-children" id="athletes"> <li class="has-children" id="athletes">
<input type="checkbox" name="athlete-selector" id="athlete-selector"> <input type="checkbox" name="athlete-selector" id="athlete-selector">
@@ -61,3 +61,4 @@
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endif %}

View File

@@ -1,45 +1,64 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load rowerfilters %} {% load rowerfilters %}
{% block title %}Rowsandall Training Plans{% endblock %} {% block title %}Rowsandall Training Plans{% endblock %}
{% block scripts %}
{% endblock %} {% block main %}
<h1>Training Plan - {{ plan.name }}</h1>
{% block content %} <p>This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}.
<div class="grid_12"> {% if plan.target %}
<div class="grid_12 alpha"> The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}.
<h1>Training Plan - {{ plan.name }}</h1>
<p>This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}.</p>
<p><a href="/rowers/editplan/{{ plan.id }}">Edit the plan</a></p>
</div>
<div class="grid_4 alpha">
<h2>Macro Cycles</h2>
</div>
<div class="grid_4 alpha">
<h2>Meso Cycles</h2>
</div>
<div class="grid_4">
<h2>Micro Cycles</h2>
</div>
</div>
<!-- Container for plan -->
<div class="grid_12 alpha">
{% now "Y-m-d" as todays_date %}
<!-- Macro Cycle for loop -->
{% for key,macrocycle in cycles.items %}
<!-- Container for Macro cycle -->
<div class="grid_12 alpha">
<!-- Macro Cycle -->
{% if macrocycle.0.type == 'filler' %}
<div class="grid_4 filler alpha">
{% else %}
<div class="grid_4 palegreen alpha">
{% endif %} {% endif %}
<!-- Padding --> </p>
<p><a href="/rowers/editplan/{{ plan.id }}">Edit the plan</a></p>
<h2>Plan Macro, Meso and Micro Cycles</h2>
<ul class="cd-accordion-menu animated">
<!-- Start Macrocycle For Loop -->
{% for key, macrocycle in cycles.items %}
<li class="has-children" id="macros">
<input type="checkbox" name="macro-selector" id="macro-selector-{{ macrocycle.0.id }}">
<label for="macro-selector-{{ macrocycle.0.id }}">Macro Cycle {{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})</label>
<ul>
<li id="macro-{{ macrocycle.0.id }}">
{% if macrocycle.0.type == 'filler' %}
<div class='filler'>
<div class="padded">
<table width="100%">
<tr>
<th colspan="4">
{{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})
</th>
</tr>
{% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %}
<tr>
&nbsp;
</tr>
<tr>
<td colspan="4">
<a href="/rowers/macrocycle/{{ macrocycle.0.id }}">edit</a>
/
<a href="/rowers/deletemacrocycle/{{ macrocycle.0.id }}">delete</a>
/
<a href='/rowers/sessions/{{ macrocycle.0.startdate|date:"Y-m-d" }}/{{ macrocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
</td>
</tr>
{% else %}
<tr>
&nbsp;
</tr>
<tr>
<a href='/rowers/sessions/{{ macrocycle.0.startdate|date:"Y-m-d" }}/{{ macrocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
</tr>
{% endif %}
</table>
</div>
</div>
{% else %}
<div class='palegreen'>
<div class="padded"> <div class="padded">
<table width="100%"> <table width="100%">
<tr> <tr>
@@ -95,27 +114,58 @@
{% endif %} {% endif %}
</table> </table>
</div> </div>
<!-- End Padding -->
</div> </div>
<!-- End Macro Cycle --> {% endif %}
<!-- Meso Cycle Container --> </li>
<div class="grid_8 alpha"> <li class="has-children" id="mesos">
<input type="checkbox" name="meso-selector" id="meso-selector-{{ macrocycle.0.id }}">
<label for="meso-selector-{{ macrocycle.0.id }}">Meso Cycles</label>
<ul>
<!-- Meso Cycle For Loop --> <!-- Meso Cycle For Loop -->
{% for key, mesocycle in macrocycle.1.items %} {% for key, mesocycle in macrocycle.1.items %}
<!-- Meso Cycle plus its Micro Cycles --> <li id="meso-{{ mesocycle.0.id }}-{{ macrocycle.0.id }}">
<div class="grid_8 alpha">
<!-- Meso Cycle -->
{% if mesocycle.0.type == 'filler' %} {% if mesocycle.0.type == 'filler' %}
<div class="grid_4 filler alpha"> <div class='filler'>
{% else %} <div class="padded">
<div class="grid_4 lightsalmon alpha">
{% endif %}
<!-- Meso Cycle Padding -->
<div class="padded alpha">
<table width="100%"> <table width="100%">
<tr> <tr>
<th colspan="4"> <th colspan="4">
{{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) Meso {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})
</th>
</tr>
{% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %}
{% if mesocycle.0.plan.type == 'userdefined' %}
<tr>
&nbsp;
</tr>
<tr>
<td colspan="4">
<a href="/rowers/mesocycle/{{ mesocycle.0.id }}">edit</a>
/
<a href="/rowers/deletemesocycle/{{ mesocycle.0.id }}">delete</a>
/
<a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
</td>
</tr>
{% endif %}
{% else %}
<tr>
&nbsp;
</tr>
<tr>
<a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
</tr>
{% endif %}
</table>
</div>
</div>
{% else %}
<div class='lightsalmon'>
<div class="padded">
<table width="100%">
<tr>
<th colspan="4">
Meso {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})
</th> </th>
</tr> </tr>
{% if mesocycle.0.type == 'userdefined' %} {% if mesocycle.0.type == 'userdefined' %}
@@ -142,7 +192,6 @@
</tr> </tr>
{% endif %} {% endif %}
{% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %} {% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %}
{% if mesocycle.0.plan.type == 'userdefined' %}
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
@@ -155,9 +204,7 @@
<a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a> <a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
</td> </td>
</tr> </tr>
{% endif %}
{% else %} {% else %}
{% if mesocycle.0.plan.type == 'userdefined' %}
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
@@ -166,54 +213,33 @@
<a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a> <a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
</td> </td>
</tr> </tr>
{% endif %}
{% endif %} {% endif %}
</table> </table>
</div> </div>
<!-- End Meso Cycle Padding -->
</div> </div>
<!-- End Meso Cycle -->
<!-- Container for Micro Cycle -->
<div class="grid_4 omega">
<!-- Micro Cycle For Loop -->
{% for microcycle in mesocycle.1 %}
<!-- Micro Cycle -->
{% if microcycle.type == 'filler' %}
<div class="grid_4 filler alpha">
{% else %}
<div class="grid_4 paleblue alpha">
{% endif %} {% endif %}
<!-- Micro Cycle Padding --> </li>
<li class="has-children" id="micros">
<input type="checkbox" name="micro-selector"
id="micro-selector-{{ macrocycle.0.id }}-{{ mesocycle.0.id }}">
<label
for="micro-selector-{{ macrocycle.0.id }}-{{ mesocycle.0.id }}">
Micro Cycles
</label>
<ul>
<!-- MicroCycle For Loop -->
{% for microcycle in mesocycle.1 %}
<li
id="micro-{{ microcycle.id }}-{{ mesocycle.0.id }}-{{ macrocycle.id }}">
{% if microcycle.type == 'filler' %}
<div class="filler">
<div class="padded"> <div class="padded">
<table width="100%"> <table width="100%">
<tr> <tr>
<th colspan="4"> <th colspan="4">
{{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }}) Micro {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})
</th> </th>
</tr> </tr>
{% if microcycle.type == 'userdefined' %}
<tr>
<td></td>
<td>dist (m)</td>
<td>t (min)</td>
<td>rScore</td>
<td>TRIMP</td>
</tr>
<tr>
<td>plan</td>
<td>{{ microcycle.plandistance }}</td>
<td>{{ microcycle.plantime }}</td>
<td>{{ microcycle.planrscore }}</td>
<td>{{ microcycle.plantrimp }}</td>
</tr>
<tr>
<td>actual</td>
<td>{{ microcycle.actualdistance }}</td>
<td>{{ microcycle.actualtime }}</td>
<td>{{ microcycle.actualrscore }}</td>
<td>{{ microcycle.actualtrimp }}</td>
</tr>
{% endif %}
{% if todays_date <= microcycle.enddate|date:"Y-m-d" %} {% if todays_date <= microcycle.enddate|date:"Y-m-d" %}
{% if microcycle.plan.type == 'userdefined' %} {% if microcycle.plan.type == 'userdefined' %}
<tr> <tr>
@@ -243,27 +269,82 @@
{% endif %} {% endif %}
</table> </table>
</div> </div>
<!-- End Micro Cycle Padding -->
</div> </div>
<!-- End Micro Cycle --> {% else %}
<div class="paleblue">
<div class="padded">
<table width="100%">
<tr>
<th colspan="4">
Micro {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})
</th>
</tr>
<tr>
<td></td>
<td>dist (m)</td>
<td>t (min)</td>
<td>rScore</td>
<td>TRIMP</td>
</tr>
<tr>
<td>plan</td>
<td>{{ microcycle.plandistance }}</td>
<td>{{ microcycle.plantime }}</td>
<td>{{ microcycle.planrscore }}</td>
<td>{{ microcycle.plantrimp }}</td>
</tr>
<tr>
<td>actual</td>
<td>{{ microcycle.actualdistance }}</td>
<td>{{ microcycle.actualtime }}</td>
<td>{{ microcycle.actualrscore }}</td>
<td>{{ microcycle.actualtrimp }}</td>
</tr>
{% if todays_date <= microcycle.enddate|date:"Y-m-d" %}
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4">
<a href="/rowers/microcycle/{{ microcycle.id }}">edit</a>
/
<a href="/rowers/deletemicrocycle/{{ microcycle.id }}">delete</a>
/
<a href='/rowers/sessions/{{ microcycle.startdate|date:"Y-m-d" }}/{{ microcycle.enddate|date:"Y-m-d" }}'>sessions</a>
</td>
</tr>
{% else %}
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4">
<a href='/rowers/sessions/{{ microcycle.startdate|date:"Y-m-d" }}/{{ microcycle.enddate|date:"Y-m-d" }}'>sessions</a>
</td>
</tr>
{% endif %}
</table>
</div>
</div>
{% endif %}
</li>
{% endfor %} {% endfor %}
<!-- End Micro Cycle For Loop --> <!-- end microcycle forloop -->
</div> </ul>
<!-- End Container for Micro Cycle --> </li>
</div>
<!-- Meso Cycle plus its Micro Cycles -->
{% endfor %} {% endfor %}
<!-- End Meso Cycle For Loop --> <!-- end mesocycle forloop -->
</div> </ul>
<!-- End Meso Cycle Container --> </li>
</div> </ul>
<!-- End Container for Macro Cycle --> </li>
{% endfor %} {% endfor %}
<!-- End Macro Cycle for loop --> <!-- end macrocycle forloop -->
</div> </ul>
<!-- End Container for plan -->
<div class="grid_12"> <p>Click on the cycle to fold out its contents.</p>
<p>Click on the plan cycles to edit their names, start and end dates.
<p>Click on the plan cycles to edit their names, start and end dates.
The gray "filler" The gray "filler"
cycles are generated, adjusted and deleted automatically to cycles are generated, adjusted and deleted automatically to
ensure the entire plan ensure the entire plan
@@ -271,13 +352,13 @@
Once you edit a filler cycle, it become a user-defined Once you edit a filler cycle, it become a user-defined
cycle, which cannot be deleted cycle, which cannot be deleted
by the system.</p> by the system.</p>
<p>Filler cycles which have a filler cycle as a parent cannot be edited <p>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 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 that children of filler cycles are not safe. They are deleted when
their parent is deleted by the system.</p> their parent is deleted by the system.</p>
<p>Click on "Sessions" in the cycle of your interest to see details <p>Click on "Sessions" in the cycle of your interest to see details
of the individual training sessions planned for this period.</p> of the individual training sessions planned for this period.</p>
<p>A good way to organize the plan is to think of micro <p>A good way to organize the plan is to think of micro
cycles as training weeks. Macro cycles cycles as training weeks. Macro cycles
are typically used to address specific phases of preparation are typically used to address specific phases of preparation
and to indicate the racing and to indicate the racing
@@ -286,5 +367,49 @@
light, medium and light, medium and
hard weeks. It is recommended to work from left to right, hard weeks. It is recommended to work from left to right,
starting with the macro cycles.</p> starting with the macro cycles.</p>
</div> {% endblock %}
{% block scripts %}
{% if thismicro %}
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
</script>
<script>
$(document).ready(function() {
console.log('#micro-selector-{{ thismicro.plan.plan.id }}-{{ thismicro.plan.id }}');
$('#micro-selector-{{ thismicro.plan.plan.id }}-{{ thismicro.plan.id }}').prop('checked',true);
$('#meso-selector-{{ thismicro.plan.plan.id }}').prop('checked',true);
$('#macro-selector-{{ thismicro.plan.plan.id }}').prop('checked',true);
$('#micro-{{ thismicro.id }}-{{ thismicro.plan.id }}-{{ thismicro.plan.plan.id }}').focus();
console.log('done')
});
</script>
{% elif thismeso %}
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
</script>
<script>
$(document).ready(function() {
$('#meso-selector-{{ thismeso.plan.id }}').prop('checked',true);
$('#macro-selector-{{ thismeso.plan.id }}').prop('checked',true);
$('#meso-{{ thismeso.id }}-{{ thismeso.plan.id }}').focus();
});
</script>
{% endif %}
{% if thismacro %}
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
</script>
<script>
$(document).ready(function() {
$('#macro-selector-{{ thismacro.id }}').prop('checked',true);
$('#macro-{{ thismacro.id }}').focus();
console.log('done')
});
</script>
{% endif %}
{% endblock %}
{% block sidebar %}
{% include 'menu_plan.html' %}
{% endblock %} {% endblock %}

View File

@@ -185,7 +185,7 @@ def get_field_id(id,s,form):
field_name = s+str(id) field_name = s+str(id)
return form.__getitem__(field_name) return form.__getitem__(field_name)
from rowers.models import Rower,Team from rowers.models import Rower,Team,TrainingPlan,TrainingTarget
from rowers.views import ispromember from rowers.views import ispromember
@register.filter @register.filter
@@ -350,3 +350,23 @@ def userurl(path,member):
replaced = path+userstring replaced = path+userstring
return replaced 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

View File

@@ -413,13 +413,20 @@ urlpatterns = [
# url(r'^workout/compare/(?P<id1>\d+)/(?P<id2>\d+)/(?P<xparam>\w+.*)/(?P<yparam>[\w\ ]+.*)/$',views.workout_comparison_view2), # url(r'^workout/compare/(?P<id1>\d+)/(?P<id2>\d+)/(?P<xparam>\w+.*)/(?P<yparam>[\w\ ]+.*)/$',views.workout_comparison_view2),
url(r'^test\_callback',views.rower_process_testcallback), url(r'^test\_callback',views.rower_process_testcallback),
url(r'^createplan/$',views.rower_create_trainingplan), url(r'^createplan/$',views.rower_create_trainingplan),
url(r'^createplan/user/(?P<userid>\d+)$',views.rower_create_trainingplan), url(r'^createplan/user/(?P<userid>\d+)/$',views.rower_create_trainingplan),
url(r'^deleteplan/(?P<pk>\d+)$',views.TrainingPlanDelete.as_view()), url(r'^deleteplan/(?P<pk>\d+)$',views.TrainingPlanDelete.as_view()),
url(r'^deletemicrocycle/(?P<pk>\d+)$',views.MicroCycleDelete.as_view()), url(r'^deletemicrocycle/(?P<pk>\d+)$',views.MicroCycleDelete.as_view()),
url(r'^deletemesocycle/(?P<pk>\d+)$',views.MesoCycleDelete.as_view()), url(r'^deletemesocycle/(?P<pk>\d+)$',views.MesoCycleDelete.as_view()),
url(r'^deletemacrocycle/(?P<pk>\d+)$',views.MacroCycleDelete.as_view()), url(r'^deletemacrocycle/(?P<pk>\d+)$',views.MacroCycleDelete.as_view()),
# url(r'^deleteplan/(?P<id>\d+)$',views.rower_delete_trainingplan), # url(r'^deleteplan/(?P<id>\d+)$',views.rower_delete_trainingplan),
url(r'^plan/(?P<id>\d+)$',views.rower_trainingplan_view), url(r'^plan/(?P<id>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/user/(?P<userid>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/micro/(?P<thismicroid>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/micro/(?P<thismicroid>\d+)/user/(?P<userid>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/meso/(?P<thismesoid>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/meso/(?P<thismesoid>\d+)/user/(?P<userid>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/macro/(?P<thismacroid>\d+)/$',views.rower_trainingplan_view),
url(r'^plan/(?P<id>\d+)/macro/(?P<thismacroid>\d+)/user/(?P<userid>\d+)/$',views.rower_trainingplan_view),
url(r'^macrocycle/(?P<pk>\d+)$',views.TrainingMacroCycleUpdate.as_view()), url(r'^macrocycle/(?P<pk>\d+)$',views.TrainingMacroCycleUpdate.as_view()),
url(r'^mesocycle/(?P<pk>\d+)$',views.TrainingMesoCycleUpdate.as_view()), url(r'^mesocycle/(?P<pk>\d+)$',views.TrainingMesoCycleUpdate.as_view()),
url(r'^microcycle/(?P<pk>\d+)$',views.TrainingMicroCycleUpdate.as_view()), url(r'^microcycle/(?P<pk>\d+)$',views.TrainingMicroCycleUpdate.as_view()),

View File

@@ -209,6 +209,8 @@ class JSONResponse(HttpResponse):
def getrequestrower(request,rowerid=0,userid=0,notpermanent=False): def getrequestrower(request,rowerid=0,userid=0,notpermanent=False):
userid = int(userid)
rowerid = int(rowerid)
if notpermanent == False: if notpermanent == False:
if rowerid == 0 and 'rowerid' in request.session: if rowerid == 0 and 'rowerid' in request.session:
@@ -15506,12 +15508,27 @@ def rower_create_trainingplan(request,userid=0):
plans = TrainingPlan.objects.filter(rower=therower).order_by("-startdate") plans = TrainingPlan.objects.filter(rower=therower).order_by("-startdate")
form = TrainingPlanForm(targets=targets) form = TrainingPlanForm(targets=targets)
breadcrumbs = [
{
'url':reverse(plannedsessions_view,
kwargs={'userid':userid}),
'name': 'Plan'
},
{
'url':reverse(rower_create_trainingplan,
kwargs={'userid':userid}),
'name': 'Manage Plans and Targets'
}
]
return render(request,'trainingplan_create.html', return render(request,'trainingplan_create.html',
{ {
'form':form, 'form':form,
'rower':therower, 'rower':therower,
'breadcrumbs':breadcrumbs,
'plans':plans, 'plans':plans,
'active':'nav-plan',
'targets':targets, 'targets':targets,
'targetform':targetform, 'targetform':targetform,
}) })
@@ -15570,9 +15587,11 @@ class MicroCycleDelete(DeleteView):
def get_success_url(self): def get_success_url(self):
plan = self.object.plan.plan.plan plan = self.object.plan.plan.plan
createmacrofillers(plan) createmacrofillers(plan)
thismesoid = self.object.plan.pk
return reverse(rower_trainingplan_view, return reverse(rower_trainingplan_view,
kwargs = { kwargs = {
'id':plan.id 'id':plan.id,
'thismesoid':thismesoid
}) })
def get_object(self, *args, **kwargs): def get_object(self, *args, **kwargs):
@@ -15588,10 +15607,12 @@ class MesoCycleDelete(DeleteView):
def get_success_url(self): def get_success_url(self):
plan = self.object.plan.plan plan = self.object.plan.plan
thismacroid = self.object.plan.pk
createmacrofillers(plan) createmacrofillers(plan)
return reverse(rower_trainingplan_view, return reverse(rower_trainingplan_view,
kwargs = { kwargs = {
'id':plan.id 'id':plan.id,
'thismacroid':thismacroid,
}) })
def get_object(self, *args, **kwargs): def get_object(self, *args, **kwargs):
@@ -15723,12 +15744,19 @@ class MacroCycleDelete(DeleteView):
@user_passes_test(hasplannedsessions,login_url="/", redirect_field_name=None) @user_passes_test(hasplannedsessions,login_url="/", redirect_field_name=None)
def rower_trainingplan_view(request,id=0): def rower_trainingplan_view(request,
id=0,
userid=0,
thismicroid=0,
thismacroid=0,
thismesoid=0):
try: try:
plan = TrainingPlan.objects.get(id=id) plan = TrainingPlan.objects.get(id=id)
except TrainingPlan.DoesNotExist: except TrainingPlan.DoesNotExist:
raise Http404("Training Plan Does Not Exist") raise Http404("Training Plan Does Not Exist")
r = getrequestrower(request,userid=userid)
if not checkaccessuser(request.user,plan.rower): if not checkaccessuser(request.user,plan.rower):
raise PermissionDenied("Access denied") raise PermissionDenied("Access denied")
@@ -15854,11 +15882,51 @@ def rower_trainingplan_view(request,id=0):
cycles[count] = (m,mesos) cycles[count] = (m,mesos)
count += 1 count += 1
breadcrumbs = [
{
'url':reverse(plannedsessions_view,
kwargs={'userid':userid}),
'name': 'Plan'
},
{
'url':reverse(rower_trainingplan_view,
kwargs={'userid':userid,
'id':id}),
'name': plan.name
}
]
if thismicroid:
thismicro = TrainingMicroCycle.objects.get(id=int(thismicroid))
else:
if not thismacroid and not thismesoid:
thismicro = get_todays_micro(plan)
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
print thismacro,thismeso,thismicro,'aap'
return render(request,'trainingplan.html', return render(request,'trainingplan.html',
{ {
'plan':plan, 'plan':plan,
'active':'nav-plan',
'breadcrumbs':breadcrumbs,
'rower':r,
'cycles':cycles, 'cycles':cycles,
'thismicro':thismicro,
'thismacro':thismacro,
'thismeso':thismeso,
} }
) )
@@ -15873,7 +15941,8 @@ class TrainingMacroCycleUpdate(UpdateView):
createmacrofillers(plan) createmacrofillers(plan)
return reverse(rower_trainingplan_view, return reverse(rower_trainingplan_view,
kwargs = { kwargs = {
'id':plan.id 'id':plan.id,
'thismacro':self.object.id,
} }
) )
@@ -15904,7 +15973,8 @@ class TrainingMesoCycleUpdate(UpdateView):
createmesofillers(plan) createmesofillers(plan)
return reverse(rower_trainingplan_view, return reverse(rower_trainingplan_view,
kwargs = { kwargs = {
'id':plan.plan.id 'id':plan.plan.id,
'thismesoid':self.object.id,
} }
) )
@@ -15938,7 +16008,8 @@ class TrainingMicroCycleUpdate(UpdateView):
createmicrofillers(plan) createmicrofillers(plan)
return reverse(rower_trainingplan_view, return reverse(rower_trainingplan_view,
kwargs = { kwargs = {
'id':plan.plan.plan.id 'id':plan.plan.plan.id,
'thismicroid':self.object.pk
} }
) )
def form_valid(self, form): def form_valid(self, form):

View File

@@ -626,6 +626,45 @@ th.rotate > div > span {
} }
/* palegreen */
.palegreen {
background: palegreen;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
/* paleblue */
.paleblue {
# padding: 8px;
background: aliceblue;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
/* lightsalmon */
.lightsalmon {
# padding: 4px;
background: lightsalmon;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
/* filler */
.filler {
background: darkgray;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
.padded {
padding: 10px;
}
.input { .input {
font: 1.1em/1.5em sans-serif; font: 1.1em/1.5em sans-serif;
text-decoration: none; text-decoration: none;
@@ -753,44 +792,6 @@ th.rotate > div > span {
} }
/* palegreen */
.palegreen {
background: palegreen;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
/* paleblue */
.paleblue {
# padding: 8px;
background: aliceblue;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
/* lightsalmon */
.lightsalmon {
# padding: 4px;
background: lightsalmon;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
/* filler */
.filler {
background: darkgray;
box-shadow:inset 0px 0px 0px 6px #fff;
-moz-box-shadow:inset 0px 0px 0px 6px #fff;
box-shadow:inset 0px 0px 0px 6px #fff;
}
.padded {
padding: 10px;
}
/* pink */ /* pink */
.pink { .pink {
color: #feeef5; color: #feeef5;

View File

@@ -201,7 +201,6 @@
aside .cd-accordion-menu label { aside .cd-accordion-menu label {
cursor: pointer; cursor: pointer;
background: #35383d;
} }
@@ -224,6 +223,84 @@
} }
main .cd-accordion-menu {
width: 100%;
max-width: 600px;
}
main .cd-accordion-menu ul {
/* by default hide all sub menus */
display: none;
}
main .cd-accordion-menu li {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
main .cd-accordion-menu input[type=checkbox] {
/* hide native checkbox */
position: absolute;
opacity: 0;
}
main .cd-accordion-menu label {
position: relative;
display: block;
font-size: 1.0em;
}
main .cd-accordion-menu ul,
main .cd-accordion-menu li {
list-style: none;
}
main .cd-accordion-menu label::before
{
/* icons */
font: normal normal normal 1.0em/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
content: '\f0da';
display: inline-block;
width: 16px;
height: 16px;
-webkit-transform: translateY(0%);
-moz-transform: translateY(0%);
-ms-transform: translateY(0%);
-o-transform: translateY(0%);
transform: translateY(0%);
}
main .cd-accordion-menu label {
cursor: pointer;
}
main .cd-accordion-menu input[type=checkbox]:checked + label::before {
/* rotate arrow */
-webkit-transform: translateY(20%) rotate(90deg);
-moz-transform: translateY(20%) rotate(90deg);
-ms-transform: translateY(20%) rotate(90deg);
-o-transform: translateY(20%) rotate(90deg);
transform: translateY(20%) rotate(90deg);
}
main .cd-accordion-menu input[type=checkbox]:checked + label + ul,
main .cd-accordion-menu input[type=checkbox]:checked + label:nth-of-type(n) + ul {
/* use label:nth-of-type(n) to fix a bug on safari (<= 8.0.8) with multiple adjacent-sibling selectors*/
/* show children when item is checked */
display: block;
}
user ul { user ul {
list-style: none; list-style: none;