mostly working - a few bugs remaining
This commit is contained in:
235
rowers/models.py
235
rowers/models.py
@@ -1073,6 +1073,7 @@ def createmacrofillers(plan):
|
|||||||
|
|
||||||
if not cycles:
|
if not cycles:
|
||||||
macr = TrainingMacroCycle(
|
macr = TrainingMacroCycle(
|
||||||
|
plan=plan,
|
||||||
startdate = plan.startdate,
|
startdate = plan.startdate,
|
||||||
enddate = plan.enddate,
|
enddate = plan.enddate,
|
||||||
type='filler',
|
type='filler',
|
||||||
@@ -1095,6 +1096,131 @@ def createmacrofillers(plan):
|
|||||||
cycles = cycles[1:]
|
cycles = cycles[1:]
|
||||||
|
|
||||||
|
|
||||||
|
def createmesofillers(plan):
|
||||||
|
fillers = TrainingMesoCycle.objects.filter(
|
||||||
|
plan = plan, type = 'filler'
|
||||||
|
)
|
||||||
|
|
||||||
|
for f in fillers:
|
||||||
|
f.delete()
|
||||||
|
|
||||||
|
cycles = TrainingMesoCycle.objects.filter(
|
||||||
|
plan = plan
|
||||||
|
).order_by("-startdate")
|
||||||
|
|
||||||
|
if not cycles:
|
||||||
|
macr = TrainingMesoCycle(
|
||||||
|
plan = plan,
|
||||||
|
startdate = plan.startdate,
|
||||||
|
enddate = plan.enddate,
|
||||||
|
type='filler',
|
||||||
|
name='Filler'
|
||||||
|
)
|
||||||
|
macr.save()
|
||||||
|
|
||||||
|
thedate = plan.enddate
|
||||||
|
while cycles:
|
||||||
|
if cycles[0].enddate < thedate:
|
||||||
|
macr = TrainingMesoCycle(
|
||||||
|
plan=plan,
|
||||||
|
startdate = cycles[0].enddate+datetime.timedelta(days=1),
|
||||||
|
enddate = thedate,
|
||||||
|
type='filler',
|
||||||
|
name='Filler'
|
||||||
|
)
|
||||||
|
macr.save()
|
||||||
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
|
cycles = cycles[1:]
|
||||||
|
|
||||||
|
|
||||||
|
def createmicrofillers(plan):
|
||||||
|
fillers = TrainingMicroCycle.objects.filter(
|
||||||
|
plan = plan, type = 'filler'
|
||||||
|
)
|
||||||
|
|
||||||
|
for f in fillers:
|
||||||
|
f.delete()
|
||||||
|
|
||||||
|
cycles = TrainingMicroCycle.objects.filter(
|
||||||
|
plan = plan
|
||||||
|
).order_by("-startdate")
|
||||||
|
|
||||||
|
if not cycles:
|
||||||
|
macr = TrainingMicroCycle(
|
||||||
|
plan=plan,
|
||||||
|
startdate = plan.startdate,
|
||||||
|
enddate = plan.enddate,
|
||||||
|
type='filler',
|
||||||
|
name='Filler'
|
||||||
|
)
|
||||||
|
macr.save()
|
||||||
|
|
||||||
|
thedate = plan.enddate
|
||||||
|
while cycles:
|
||||||
|
if cycles[0].enddate < thedate:
|
||||||
|
macr = TrainingMicroCycle(
|
||||||
|
plan=plan,
|
||||||
|
startdate = cycles[0].enddate+datetime.timedelta(days=1),
|
||||||
|
enddate = thedate,
|
||||||
|
type='filler',
|
||||||
|
name='Filler'
|
||||||
|
)
|
||||||
|
macr.save()
|
||||||
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
|
cycles = cycles[1:]
|
||||||
|
|
||||||
|
def microcyclecheckdates(plan):
|
||||||
|
cycles = TrainingMicroCycle.objects.filter(
|
||||||
|
plan=plan
|
||||||
|
).order_by("-startdate")
|
||||||
|
|
||||||
|
thedate = plan.enddate
|
||||||
|
while cycles:
|
||||||
|
if cycles[0].enddate < plan.startdate:
|
||||||
|
cycles[0].delete()
|
||||||
|
if cycles[0].startdate > plan.enddate:
|
||||||
|
cycles[0].delete()
|
||||||
|
if cycles[0].enddate > thedate:
|
||||||
|
cycles[0].enddate = thedate
|
||||||
|
cycles[0].save()
|
||||||
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
|
cycles = cycles[1:]
|
||||||
|
|
||||||
|
def mesocyclecheckdates(plan):
|
||||||
|
cycles = TrainingMesoCycle.objects.filter(
|
||||||
|
plan=plan
|
||||||
|
).order_by("-startdate")
|
||||||
|
|
||||||
|
thedate = plan.enddate
|
||||||
|
while cycles:
|
||||||
|
if cycles[0].enddate < plan.startdate:
|
||||||
|
cycles[0].delete()
|
||||||
|
if cycles[0].startdate > plan.enddate:
|
||||||
|
cycles[0].delete()
|
||||||
|
if cycles[0].enddate > thedate:
|
||||||
|
cycles[0].enddate = thedate
|
||||||
|
cycles[0].save()
|
||||||
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
|
cycles = cycles[1:]
|
||||||
|
|
||||||
|
def macrocyclecheckdates(plan):
|
||||||
|
cycles = TrainingMacroCycle.objects.filter(
|
||||||
|
plan=plan
|
||||||
|
).order_by("-startdate")
|
||||||
|
|
||||||
|
thedate = plan.enddate
|
||||||
|
while cycles:
|
||||||
|
if cycles[0].enddate < plan.startdate:
|
||||||
|
cycles[0].delete()
|
||||||
|
if cycles[0].startdate > plan.enddate:
|
||||||
|
cycles[0].delete()
|
||||||
|
if cycles[0].enddate > thedate:
|
||||||
|
cycles[0].enddate = thedate
|
||||||
|
cycles[0].save()
|
||||||
|
thedate = cycles[0].startdate-datetime.timedelta(days=1)
|
||||||
|
cycles = cycles[1:]
|
||||||
|
|
||||||
|
|
||||||
class TrainingMacroCycle(models.Model):
|
class TrainingMacroCycle(models.Model):
|
||||||
plan = models.ForeignKey(TrainingPlan)
|
plan = models.ForeignKey(TrainingPlan)
|
||||||
name = models.CharField(max_length=150,blank=True)
|
name = models.CharField(max_length=150,blank=True)
|
||||||
@@ -1127,6 +1253,12 @@ class TrainingMacroCycle(models.Model):
|
|||||||
for f in fillers:
|
for f in fillers:
|
||||||
f.delete()
|
f.delete()
|
||||||
|
|
||||||
|
if self.enddate > self.plan.enddate:
|
||||||
|
self.enddate = self.plan.enddate
|
||||||
|
|
||||||
|
if self.startdate < self.plan.startdate:
|
||||||
|
self.startdate = self.plan.startdate
|
||||||
|
|
||||||
othercycles = TrainingMacroCycle.objects.filter(
|
othercycles = TrainingMacroCycle.objects.filter(
|
||||||
plan=self.plan).exclude(pk=self.pk).order_by("-startdate")
|
plan=self.plan).exclude(pk=self.pk).order_by("-startdate")
|
||||||
|
|
||||||
@@ -1151,11 +1283,13 @@ class TrainingMacroCycle(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
meso.save()
|
meso.save()
|
||||||
|
else:
|
||||||
|
createmesofillers(self)
|
||||||
|
|
||||||
class TrainingMacroCycleForm(ModelForm):
|
class TrainingMacroCycleForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TrainingMacroCycle
|
model = TrainingMacroCycle
|
||||||
fields = ['name','startdate','enddate']
|
fields = ['name','startdate','enddate','notes']
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
'startdate': AdminDateWidget(),
|
'startdate': AdminDateWidget(),
|
||||||
@@ -1181,6 +1315,49 @@ class TrainingMesoCycle(models.Model):
|
|||||||
|
|
||||||
return stri
|
return stri
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.enddate < self.startdate:
|
||||||
|
startdate = self.startdate
|
||||||
|
enddate = self.enddate
|
||||||
|
self.startdate = enddate
|
||||||
|
self.enddate = startdate
|
||||||
|
|
||||||
|
fillers = TrainingMesoCycle.objects.filter(
|
||||||
|
plan=self.plan,type='filler')
|
||||||
|
for f in fillers:
|
||||||
|
f.delete()
|
||||||
|
|
||||||
|
if self.enddate > self.plan.enddate:
|
||||||
|
self.enddate = self.plan.enddate
|
||||||
|
|
||||||
|
if self.startdate < self.plan.startdate:
|
||||||
|
self.startdate = self.plan.startdate
|
||||||
|
|
||||||
|
othercycles = TrainingMesoCycle.objects.filter(
|
||||||
|
plan=self.plan).exclude(pk=self.pk).order_by("-startdate")
|
||||||
|
|
||||||
|
for othercycle in othercycles:
|
||||||
|
if othercycle.startdate <= self.enddate and othercycle.startdate >= self.startdate:
|
||||||
|
self.enddate = othercycle.startdate-datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
if othercycle.enddate >= self.startdate and othercycle.enddate <= self.enddate:
|
||||||
|
self.startdate = othercycle.enddate+datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
if not self.enddate <= self.startdate:
|
||||||
|
super(TrainingMesoCycle,self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
microcycles = TrainingMicroCycle.objects.filter(plan = self)
|
||||||
|
if not microcycles:
|
||||||
|
micro = TrainingMicroCycle(
|
||||||
|
plan = self,
|
||||||
|
name = 'Filler',
|
||||||
|
startdate = self.startdate,
|
||||||
|
enddate = self.enddate,
|
||||||
|
)
|
||||||
|
|
||||||
|
micro.save()
|
||||||
|
else:
|
||||||
|
createmicrofillers(self)
|
||||||
|
|
||||||
class TrainingMicroCycle(models.Model):
|
class TrainingMicroCycle(models.Model):
|
||||||
plan = models.ForeignKey(TrainingMesoCycle)
|
plan = models.ForeignKey(TrainingMesoCycle)
|
||||||
@@ -1201,15 +1378,57 @@ class TrainingMicroCycle(models.Model):
|
|||||||
|
|
||||||
return stri
|
return stri
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.enddate < self.startdate:
|
||||||
|
startdate = self.startdate
|
||||||
|
enddate = self.enddate
|
||||||
|
self.startdate = enddate
|
||||||
|
self.enddate = startdate
|
||||||
|
|
||||||
# Needs some error checking
|
fillers = TrainingMicroCycle.objects.filter(
|
||||||
# - Microcycles should not overlap with other microcycles, same for MesoCycles, MacroCycles
|
plan=self.plan,type='filler')
|
||||||
# - When a TrainingPlan is created, it should create 1 "collector" Macro, Meso & MicroCycle - this is invisible for users who choose to not use cycles
|
for f in fillers:
|
||||||
# - When a new Microcycle is inserted, the "collector" cycle is automatically adjusted to "go out of the way" of the new MicroCycle - and similar for Macro & Meso
|
f.delete()
|
||||||
# - If the entire MesoCycle is filled with user defined MicroCycles - there are no "filler" MicroCycles
|
|
||||||
# - Sessions are automatically linked to the correct Cycles based on their start/end date - no need for a hard link
|
if self.enddate > self.plan.enddate:
|
||||||
|
self.enddate = self.plan.enddate
|
||||||
|
|
||||||
|
if self.startdate < self.plan.startdate:
|
||||||
|
self.startdate = self.plan.startdate
|
||||||
|
|
||||||
|
othercycles = TrainingMicroCycle.objects.filter(
|
||||||
|
plan=self.plan).exclude(pk=self.pk).order_by("-startdate")
|
||||||
|
|
||||||
|
for othercycle in othercycles:
|
||||||
|
if othercycle.startdate <= self.enddate and othercycle.startdate >= self.startdate:
|
||||||
|
self.enddate = othercycle.startdate-datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
if othercycle.enddate >= self.startdate and othercycle.enddate <= self.enddate:
|
||||||
|
self.startdate = othercycle.enddate+datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
if not self.enddate <= self.startdate:
|
||||||
|
super(TrainingMicroCycle,self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
class TrainingMesoCycleForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = TrainingMesoCycle
|
||||||
|
fields = ['name','startdate','enddate','notes']
|
||||||
|
|
||||||
|
widgets = {
|
||||||
|
'startdate': AdminDateWidget(),
|
||||||
|
'enddate': AdminDateWidget()
|
||||||
|
}
|
||||||
|
|
||||||
|
class TrainingMicroCycleForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = TrainingMicroCycle
|
||||||
|
fields = ['name','startdate','enddate','notes']
|
||||||
|
|
||||||
|
widgets = {
|
||||||
|
'startdate': AdminDateWidget(),
|
||||||
|
'enddate': AdminDateWidget()
|
||||||
|
}
|
||||||
|
|
||||||
# Cycle error checking goes in forms
|
|
||||||
|
|
||||||
# model for Planned Session (Workout, Challenge, Test)
|
# model for Planned Session (Workout, Challenge, Test)
|
||||||
class PlannedSession(models.Model):
|
class PlannedSession(models.Model):
|
||||||
|
|||||||
@@ -18,43 +18,48 @@
|
|||||||
<div class="grid_12">
|
<div class="grid_12">
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
<h1>Training Plan - {{ plan.name }}</h1>
|
<h1>Training Plan - {{ plan.name }}</h1>
|
||||||
|
<p><a href="/rowers/editplan/{{ plan.id }}">Edit</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 alpha">
|
||||||
<h2>Macro Cycles</h2>
|
<h2>Macro Cycles</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4">
|
<div class="grid_4 alpha">
|
||||||
<h2>Meso Cycles</h2>
|
<h2>Meso Cycles</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 omega">
|
<div class="grid_4">
|
||||||
<h2>Micro Cycles</h2>
|
<h2>Micro Cycles</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_12">
|
<div class="grid_12 alpha">
|
||||||
{% for key,macrocycle in cycles.items %}
|
{% for key,macrocycle in cycles.items %}
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 palegreen alpha">
|
||||||
<h3>{{ macrocycle.0.name }}</h3>
|
<div class="padded">
|
||||||
<p>{{ macrocycle.0.startdate }}</p>
|
<h3>{{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})</h3>
|
||||||
<p>{{ macrocycle.0.enddate }}</p>
|
<p><a href="/rowers/macrocycle/{{ macrocycle.0.id }}">edit</a></p>
|
||||||
<p><a href="/rowers/macrocycle/{{ macrocycle.0.id }}">edit</a></p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_8 omega">
|
<div class="grid_8 alpha">
|
||||||
{% for key, mesocycle in macrocycle.1.items %}
|
{% for key, mesocycle in macrocycle.1.items %}
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 lightsalmon alpha">
|
||||||
{{ mesocycle.0 }}
|
<div class="padded">
|
||||||
|
<h3>{{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})</h3>
|
||||||
|
<p><a href="/rowers/mesocycle/{{ mesocycle.0.id }}">edit</a></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 omega">
|
<div class="grid_4 omega">
|
||||||
{% for key, microcycle in mesocycle.1.items %}
|
{% for microcycle in mesocycle.1 %}
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_4 paleblue ">
|
||||||
{{ microcycle }}
|
<div class="padded">
|
||||||
|
<h3>{{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})</h3>
|
||||||
|
<p><a href="/rowers/microcycle/{{ microcycle.id }}">edit</a></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -424,6 +424,8 @@ urlpatterns = [
|
|||||||
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'^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'^microcycle/(?P<pk>\d+)$',views.TrainingMicroCycleUpdate.as_view()),
|
||||||
url(r'^deletetarget/(?P<id>\d+)$',views.rower_delete_trainingtarget),
|
url(r'^deletetarget/(?P<id>\d+)$',views.rower_delete_trainingtarget),
|
||||||
url(r'^editplan/(?P<pk>\d+)$',views.TrainingPlanUpdate.as_view()),
|
url(r'^editplan/(?P<pk>\d+)$',views.TrainingPlanUpdate.as_view()),
|
||||||
url(r'^edittarget/(?P<pk>\d+)$',views.TrainingTargetUpdate.as_view()),
|
url(r'^edittarget/(?P<pk>\d+)$',views.TrainingTargetUpdate.as_view()),
|
||||||
|
|||||||
@@ -71,7 +71,10 @@ from rowers.models import (
|
|||||||
TrainingPlan,TrainingPlanForm,TrainingTarget,TrainingTargetForm,
|
TrainingPlan,TrainingPlanForm,TrainingTarget,TrainingTargetForm,
|
||||||
TrainingMacroCycle,TrainingMesoCycle,TrainingMicroCycle,
|
TrainingMacroCycle,TrainingMesoCycle,TrainingMicroCycle,
|
||||||
TrainingTarget,TrainingTargetForm,
|
TrainingTarget,TrainingTargetForm,
|
||||||
TrainingMacroCycleForm,createmacrofillers
|
TrainingMacroCycleForm,createmacrofillers,
|
||||||
|
createmicrofillers, createmesofillers,
|
||||||
|
microcyclecheckdates,mesocyclecheckdates,macrocyclecheckdates,
|
||||||
|
TrainingMesoCycleForm, TrainingMicroCycleForm,
|
||||||
)
|
)
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
||||||
@@ -14279,6 +14282,7 @@ def rower_trainingplan_view(request,id=0):
|
|||||||
if not checkaccessuser(request.user,plan.rower):
|
if not checkaccessuser(request.user,plan.rower):
|
||||||
raise PermissionDenied("Access denied")
|
raise PermissionDenied("Access denied")
|
||||||
|
|
||||||
|
createmacrofillers(plan)
|
||||||
macrocycles = TrainingMacroCycle.objects.filter(plan=plan).order_by("startdate")
|
macrocycles = TrainingMacroCycle.objects.filter(plan=plan).order_by("startdate")
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
@@ -14286,10 +14290,12 @@ def rower_trainingplan_view(request,id=0):
|
|||||||
|
|
||||||
|
|
||||||
for m in macrocycles:
|
for m in macrocycles:
|
||||||
|
createmesofillers(m)
|
||||||
mesocycles = TrainingMesoCycle.objects.filter(plan=m).order_by("startdate")
|
mesocycles = TrainingMesoCycle.objects.filter(plan=m).order_by("startdate")
|
||||||
mesos = {}
|
mesos = {}
|
||||||
count2 = 0
|
count2 = 0
|
||||||
for me in mesocycles:
|
for me in mesocycles:
|
||||||
|
createmicrofillers(me)
|
||||||
microcycles = TrainingMicroCycle.objects.filter(plan=me).order_by("startdate")
|
microcycles = TrainingMicroCycle.objects.filter(plan=me).order_by("startdate")
|
||||||
mesos[count2] = (me, microcycles)
|
mesos[count2] = (me, microcycles)
|
||||||
count2 += 1
|
count2 += 1
|
||||||
@@ -14318,8 +14324,12 @@ class TrainingMacroCycleUpdate(UpdateView):
|
|||||||
'id':plan.id
|
'id':plan.id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
form.instance.user = self.request.user
|
||||||
|
form.instance.post_date = datetime.datetime.now()
|
||||||
macrocycle = form.save()
|
macrocycle = form.save()
|
||||||
|
mesocyclecheckdates(macrocycle)
|
||||||
return super(TrainingMacroCycleUpdate, self).form_valid(form)
|
return super(TrainingMacroCycleUpdate, self).form_valid(form)
|
||||||
|
|
||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
@@ -14331,6 +14341,68 @@ class TrainingMacroCycleUpdate(UpdateView):
|
|||||||
obj.save()
|
obj.save()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
class TrainingMesoCycleUpdate(UpdateView):
|
||||||
|
model = TrainingMesoCycle
|
||||||
|
template_name = 'trainingplan_edit.html'
|
||||||
|
form_class = TrainingMesoCycleForm
|
||||||
|
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
plan = self.object.plan
|
||||||
|
createmesofillers(plan)
|
||||||
|
return reverse(rower_trainingplan_view,
|
||||||
|
kwargs = {
|
||||||
|
'id':plan.plan.id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.instance.user = self.request.user
|
||||||
|
form.instance.post_date = datetime.datetime.now()
|
||||||
|
mesocycle = form.save()
|
||||||
|
microcyclecheckdates(mesocycle)
|
||||||
|
return super(TrainingMesoCycleUpdate, self).form_valid(form)
|
||||||
|
|
||||||
|
def get_object(self, *args, **kwargs):
|
||||||
|
obj = super(TrainingMesoCycleUpdate, self).get_object(*args, **kwargs)
|
||||||
|
r = obj.plan.plan.rower
|
||||||
|
if not checkaccessuser(self.request.user,r):
|
||||||
|
raise Http404
|
||||||
|
else:
|
||||||
|
obj.type = 'userdefined'
|
||||||
|
obj.save()
|
||||||
|
return obj
|
||||||
|
|
||||||
|
class TrainingMicroCycleUpdate(UpdateView):
|
||||||
|
model = TrainingMicroCycle
|
||||||
|
template_name = 'trainingplan_edit.html'
|
||||||
|
form_class = TrainingMicroCycleForm
|
||||||
|
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
plan = self.object.plan
|
||||||
|
createmicrofillers(plan)
|
||||||
|
return reverse(rower_trainingplan_view,
|
||||||
|
kwargs = {
|
||||||
|
'id':plan.plan.plan.id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.instance.user = self.request.user
|
||||||
|
form.instance.post_date = datetime.datetime.now()
|
||||||
|
microcycle = form.save()
|
||||||
|
return super(TrainingMicroCycleUpdate, self).form_valid(form)
|
||||||
|
|
||||||
|
def get_object(self, *args, **kwargs):
|
||||||
|
obj = super(TrainingMicroCycleUpdate, self).get_object(*args, **kwargs)
|
||||||
|
r = obj.plan.plan.plan.rower
|
||||||
|
if not checkaccessuser(self.request.user,r):
|
||||||
|
raise Http404
|
||||||
|
else:
|
||||||
|
obj.type = 'userdefined'
|
||||||
|
obj.save()
|
||||||
|
return obj
|
||||||
|
|
||||||
class TrainingPlanUpdate(UpdateView):
|
class TrainingPlanUpdate(UpdateView):
|
||||||
model = TrainingPlan
|
model = TrainingPlan
|
||||||
template_name = 'trainingplan_edit.html'
|
template_name = 'trainingplan_edit.html'
|
||||||
@@ -14343,6 +14415,7 @@ class TrainingPlanUpdate(UpdateView):
|
|||||||
form.instance.user = self.request.user
|
form.instance.user = self.request.user
|
||||||
form.instance.post_date = datetime.datetime.now()
|
form.instance.post_date = datetime.datetime.now()
|
||||||
plan = form.save()
|
plan = form.save()
|
||||||
|
macrocyclecheckdates(plan)
|
||||||
return super(TrainingPlanUpdate, self).form_valid(form)
|
return super(TrainingPlanUpdate, self).form_valid(form)
|
||||||
|
|
||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
|
|||||||
@@ -490,6 +490,36 @@ a.button {
|
|||||||
color: #a9c08c;
|
color: #a9c08c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.padded {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* pink */
|
/* pink */
|
||||||
.pink {
|
.pink {
|
||||||
color: #feeef5;
|
color: #feeef5;
|
||||||
|
|||||||
Reference in New Issue
Block a user