Private
Public Access
1
0

bug fix in training planning

This commit is contained in:
Sander Roosendaal
2018-10-18 16:54:15 +02:00
parent 1c2ca96934
commit 19443f59f0
3 changed files with 57 additions and 35 deletions

View File

@@ -370,40 +370,40 @@
{% endblock %}
{% block scripts %}
{% if thismicro %}
{% if thismicroid %}
<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('#micro-selector-{{ thismicroid|micromacroid }}-{{ thismicroid|micromesoid }}');
$('#micro-selector-{{ thismicroid|micromacroid }}-{{ thismicroid|micromesoid }}').prop('checked',true);
$('#meso-selector-{{ thismicroid|micromacroid }}').prop('checked',true);
$('#macro-selector-{{ thismicroid|micromacroid }}').prop('checked',true);
$('#micro-{{ thismicroid }}-{{ thismicroid|micromesoid }}-{{ thismicroid|micromacroid }}').focus();
console.log('done')
});
</script>
{% elif thismeso %}
{% elif thismesoid %}
<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();
$('#meso-selector-{{ thismesoid|mesomacroid }}').prop('checked',true);
$('#macro-selector-{{ thismesoid|mesomacroid }}').prop('checked',true);
$('#meso-{{ thismesoid }}-{{ thismesoid|mesomacroid }}').focus();
});
</script>
{% endif %}
{% if thismacro %}
{% if thismacroid %}
<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();
$('#macro-selector-{{ thismacroid }}').prop('checked',true);
$('#macro-{{ thismacroid }}').focus();
console.log('done')
});
</script>

View File

@@ -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)

View File

@@ -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,
}
)