adding plan/actual in plan view
This commit is contained in:
@@ -1313,10 +1313,21 @@ class TrainingMacroCycle(models.Model):
|
|||||||
enddate = models.DateField(
|
enddate = models.DateField(
|
||||||
default=half_year_from_now)
|
default=half_year_from_now)
|
||||||
notes = models.TextField(max_length=300,blank=True)
|
notes = models.TextField(max_length=300,blank=True)
|
||||||
|
|
||||||
type = models.CharField(default='filler',
|
type = models.CharField(default='filler',
|
||||||
choices=cycletypechoices,
|
choices=cycletypechoices,
|
||||||
max_length=150)
|
max_length=150)
|
||||||
|
|
||||||
|
plantime = models.IntegerField(default=0,verbose_name='Planned Duration')
|
||||||
|
plandistance = models.IntegerField(default=0,verbose_name='Planned Distance')
|
||||||
|
planrscore = models.IntegerField(default=0,verbose_name='Planned rScore')
|
||||||
|
plantrimp = models.IntegerField(default=0,verbose_name='Planned TRIMP')
|
||||||
|
|
||||||
|
actualtime = models.IntegerField(default=0,verbose_name='Actual Duration')
|
||||||
|
actualdistance = models.IntegerField(default=0,verbose_name='Actual Distance')
|
||||||
|
actualrscore = models.IntegerField(default=0,verbose_name='Actual rScore')
|
||||||
|
actualtrimp = models.IntegerField(default=0,verbose_name='Actual TRIMP')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
stri = 'Macro Cycle - {n} ({sd} - {ed})'.format(
|
stri = 'Macro Cycle - {n} ({sd} - {ed})'.format(
|
||||||
n = self.name,
|
n = self.name,
|
||||||
@@ -1391,6 +1402,18 @@ class TrainingMesoCycle(models.Model):
|
|||||||
type = models.CharField(default='filler',
|
type = models.CharField(default='filler',
|
||||||
choices=cycletypechoices,
|
choices=cycletypechoices,
|
||||||
max_length=150)
|
max_length=150)
|
||||||
|
|
||||||
|
plantime = models.IntegerField(default=0,verbose_name='Planned Duration')
|
||||||
|
plandistance = models.IntegerField(default=0,verbose_name='Planned Distance')
|
||||||
|
planrscore = models.IntegerField(default=0,verbose_name='Planned rScore')
|
||||||
|
plantrimp = models.IntegerField(default=0,verbose_name='Planned TRIMP')
|
||||||
|
|
||||||
|
actualtime = models.IntegerField(default=0,verbose_name='Actual Duration')
|
||||||
|
actualdistance = models.IntegerField(default=0,verbose_name='Actual Distance')
|
||||||
|
actualrscore = models.IntegerField(default=0,verbose_name='Actual rScore')
|
||||||
|
actualtrimp = models.IntegerField(default=0,verbose_name='Actual TRIMP')
|
||||||
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
stri = 'Meso Cycle - {n} ({sd} - {ed})'.format(
|
stri = 'Meso Cycle - {n} ({sd} - {ed})'.format(
|
||||||
n = self.name,
|
n = self.name,
|
||||||
@@ -1454,6 +1477,20 @@ class TrainingMicroCycle(models.Model):
|
|||||||
type = models.CharField(default='filler',
|
type = models.CharField(default='filler',
|
||||||
choices=cycletypechoices,
|
choices=cycletypechoices,
|
||||||
max_length=150)
|
max_length=150)
|
||||||
|
|
||||||
|
plantime = models.IntegerField(default=0,verbose_name='Planned Duration')
|
||||||
|
plandistance = models.IntegerField(default=0,verbose_name='Planned Distance')
|
||||||
|
planrscore = models.IntegerField(default=0,verbose_name='Planned rScore')
|
||||||
|
plantrimp = models.IntegerField(default=0,verbose_name='Planned TRIMP')
|
||||||
|
|
||||||
|
actualtime = models.IntegerField(default=0,verbose_name='Actual Duration')
|
||||||
|
actualdistance = models.IntegerField(default=0,verbose_name='Actual Distance')
|
||||||
|
actualrscore = models.IntegerField(default=0,verbose_name='Actual rScore')
|
||||||
|
actualtrimp = models.IntegerField(default=0,verbose_name='Actual TRIMP')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
stri = 'Micro Cycle - {n} ({sd} - {ed})'.format(
|
stri = 'Micro Cycle - {n} ({sd} - {ed})'.format(
|
||||||
n = self.name,
|
n = self.name,
|
||||||
@@ -1491,6 +1528,8 @@ class TrainingMicroCycle(models.Model):
|
|||||||
if othercycle.enddate >= self.startdate and othercycle.enddate <= self.enddate:
|
if othercycle.enddate >= self.startdate and othercycle.enddate <= self.enddate:
|
||||||
self.startdate = othercycle.enddate+datetime.timedelta(days=1)
|
self.startdate = othercycle.enddate+datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not self.enddate <= self.startdate:
|
if not self.enddate <= self.startdate:
|
||||||
super(TrainingMicroCycle,self).save(*args, **kwargs)
|
super(TrainingMicroCycle,self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -306,10 +306,10 @@ def is_session_complete_ws(ws,ps):
|
|||||||
for record in vs:
|
for record in vs:
|
||||||
if record.workoutid in wids:
|
if record.workoutid in wids:
|
||||||
if record.coursecompleted:
|
if record.coursecompleted:
|
||||||
ratio = record.distance/ps.sessionvalue
|
ratio = record.distance/float(ps.sessionvalue)
|
||||||
return ratio,'completed',completiondate
|
return ratio,'completed',completiondate
|
||||||
else:
|
else:
|
||||||
ratio = record.distance/ps.sessionvalue
|
ratio = record.distance/float(ps.sessionvalue)
|
||||||
return ratio,'partial',completiondate
|
return ratio,'partial',completiondate
|
||||||
|
|
||||||
# we're still here - no record, need to create one
|
# we're still here - no record, need to create one
|
||||||
@@ -338,6 +338,7 @@ def is_session_complete_ws(ws,ps):
|
|||||||
def is_session_complete(r,ps):
|
def is_session_complete(r,ps):
|
||||||
status = 'not done'
|
status = 'not done'
|
||||||
|
|
||||||
|
|
||||||
if r not in ps.rower.all():
|
if r not in ps.rower.all():
|
||||||
return 0,'not assigned',None
|
return 0,'not assigned',None
|
||||||
|
|
||||||
|
|||||||
@@ -40,18 +40,49 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_4 palegreen alpha">
|
<div class="grid_4 palegreen alpha">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="padded">
|
<div class="padded">
|
||||||
<h3>{{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})</h3>
|
<table width="100%">
|
||||||
{% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %}
|
<tr>
|
||||||
<p><a href="/rowers/macrocycle/{{ macrocycle.0.id }}">edit</a>
|
<th colspan="4">
|
||||||
/
|
{{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})
|
||||||
<a href="/rowers/deletemacrocycle/{{ macrocycle.0.id }}">delete</a>
|
</th>
|
||||||
/
|
</tr>
|
||||||
<a href='/rowers/sessions/{{ macrocycle.0.startdate|date:"Y-m-d" }}/{{ macrocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
|
<tr>
|
||||||
</p>
|
<td></td>
|
||||||
{% else %}
|
<td>dist (m)</td>
|
||||||
<p> </p>
|
<td>t (min)</td>
|
||||||
{% endif %}
|
<td>rScore</td>
|
||||||
|
<td>TRIMP</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>plan</td>
|
||||||
|
<td>{{ macrocycle.0.plandistance }}</td>
|
||||||
|
<td>{{ macrocycle.0.plantime }}</td>
|
||||||
|
<td>{{ maccrocycle.0.planrscore }}</td>
|
||||||
|
<td>{{ macrocycle.0.plantrimp }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>actual</td>
|
||||||
|
<td>{{ macrocycle.0.actualdistance }}</td>
|
||||||
|
<td>{{ macrocycle.0.actualtime }}</td>
|
||||||
|
<td>{{ macrocycle.0.actualrscore }}</td>
|
||||||
|
<td>{{ macrocycle.0.actualtrimp }}</td>
|
||||||
|
</tr>
|
||||||
|
{% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %}
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
</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>
|
||||||
|
{% endif %}
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_8 alpha">
|
<div class="grid_8 alpha">
|
||||||
@@ -59,55 +90,115 @@
|
|||||||
{% if mesocycle.0.type == 'filler' %}
|
{% if mesocycle.0.type == 'filler' %}
|
||||||
<div class="grid_4 filler alpha">
|
<div class="grid_4 filler alpha">
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_4 lightsalmon alpha">
|
<div class="grid_4 lightsalmon alpha">
|
||||||
|
{% endif %}
|
||||||
|
<div class="padded">
|
||||||
|
<table width="100%">
|
||||||
|
<tr>
|
||||||
|
<th colspan="4">
|
||||||
|
{{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
{% if mesocycle.0.plan.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>{{ mesocycle.0.plandistance }}</td>
|
||||||
|
<td>{{ mesocycle.0.plantime }}</td>
|
||||||
|
<td>{{ mesocycle.0.planrscore }}</td>
|
||||||
|
<td>{{ mesocycle.0.plantrimp }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>actual</td>
|
||||||
|
<td>{{ mesocycle.0.actualdistance }}</td>
|
||||||
|
<td>{{ mesocycle.0.actualtime }}</td>
|
||||||
|
<td>{{ mesocycle.0.actualrscore }}</td>
|
||||||
|
<td>{{ mesocycle.0.actualtrimp }}</td>
|
||||||
|
</tr>
|
||||||
|
{% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %}
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">
|
||||||
|
<a href="/rowers/microcycle/{{ mesocycle.0.id }}">edit</a>
|
||||||
|
/
|
||||||
|
<a href="/rowers/deletemicrocycle/{{ 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 %}
|
||||||
|
{% endif %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid_4 omega">
|
||||||
|
{% for microcycle in mesocycle.1 %}
|
||||||
|
{% if microcycle.type == 'filler' %}
|
||||||
|
<div class="grid_4 filler">
|
||||||
|
{% else %}
|
||||||
|
<div class="grid_4 paleblue ">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="padded">
|
<div class="padded">
|
||||||
<h3>{{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }})</h3>
|
<table width="100%">
|
||||||
{% if mesocycle.0.plan.type == 'userdefined' %}
|
<tr>
|
||||||
{% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %}
|
<th colspan="4">
|
||||||
<p><a href="/rowers/mesocycle/{{ mesocycle.0.id }}">edit</a>
|
{{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})
|
||||||
/
|
</th>
|
||||||
<a href="/rowers/deletemesocycle/{{ mesocycle.0.id }}">delete</a>
|
</tr>
|
||||||
/
|
{% if microcycle.plan.type == 'userdefined' %}
|
||||||
<a href='/rowers/sessions/{{ mesocycle.0.startdate|date:"Y-m-d" }}/{{ mesocycle.0.enddate|date:"Y-m-d" }}'>sessions</a>
|
<tr>
|
||||||
|
<td></td>
|
||||||
</p>
|
<td>dist (m)</td>
|
||||||
{% endif %}
|
<td>t (min)</td>
|
||||||
{% else %}
|
<td>rScore</td>
|
||||||
<p> </p>
|
<td>TRIMP</td>
|
||||||
{% endif %}
|
</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> </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>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 omega">
|
{% endfor %}
|
||||||
{% for microcycle in mesocycle.1 %}
|
|
||||||
{% if microcycle.type == 'filler' %}
|
|
||||||
<div class="grid_4 filler">
|
|
||||||
{% else %}
|
|
||||||
<div class="grid_4 paleblue ">
|
|
||||||
{% endif %}
|
|
||||||
<div class="padded">
|
|
||||||
<h3>{{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }})</h3>
|
|
||||||
{% if microcycle.plan.type == 'userdefined' %}
|
|
||||||
{% if todays_date <= microcycle.enddate|date:"Y-m-d" %}
|
|
||||||
<p>
|
|
||||||
<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>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
<p> </p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_12">
|
<div class="grid_12">
|
||||||
<p>Click on the plan cycles to edit their names, start and end dates. The gray "filler"
|
<p>Click on the plan cycles to edit their names, start and end dates. The gray "filler"
|
||||||
|
|||||||
@@ -14499,17 +14499,98 @@ def rower_trainingplan_view(request,id=0):
|
|||||||
count = 0
|
count = 0
|
||||||
cycles = {}
|
cycles = {}
|
||||||
|
|
||||||
|
r = plan.rower
|
||||||
|
|
||||||
for m in macrocycles:
|
for m in macrocycles:
|
||||||
createmesofillers(m)
|
createmesofillers(m)
|
||||||
|
m.plantime = 0
|
||||||
|
m.actualtime = 0
|
||||||
|
m.plandistance = 0
|
||||||
|
m.actualdistance = 0
|
||||||
|
m.planrscore = 0
|
||||||
|
m.actualrscore = 0
|
||||||
|
m.plantrimp = 0
|
||||||
|
m.actualtrimp = 0
|
||||||
|
|
||||||
|
|
||||||
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)
|
createmicrofillers(me)
|
||||||
|
me.plantime = 0
|
||||||
|
me.actualtime = 0
|
||||||
|
me.plandistance = 0
|
||||||
|
me.actualdistance = 0
|
||||||
|
me.planrscore = 0
|
||||||
|
me.actualrscore = 0
|
||||||
|
me.plantrimp = 0
|
||||||
|
me.actualtrimp = 0
|
||||||
|
|
||||||
microcycles = TrainingMicroCycle.objects.filter(plan=me).order_by("startdate")
|
microcycles = TrainingMicroCycle.objects.filter(plan=me).order_by("startdate")
|
||||||
|
|
||||||
|
for mm in microcycles:
|
||||||
|
sps = PlannedSession.objects.filter(
|
||||||
|
rower = plan.rower,
|
||||||
|
startdate__lte=mm.enddate,
|
||||||
|
enddate__gte=mm.startdate)
|
||||||
|
|
||||||
|
|
||||||
|
mm.plantime = 0
|
||||||
|
mm.actualtime = 0
|
||||||
|
mm.plandistance = 0
|
||||||
|
mm.actualdistance = 0
|
||||||
|
mm.planrscore = 0
|
||||||
|
mm.actualrscore = 0
|
||||||
|
mm.plantrimp = 0
|
||||||
|
mm.actualtrimp = 0
|
||||||
|
|
||||||
|
|
||||||
|
if mm.type == 'userdefined':
|
||||||
|
for ps in sps:
|
||||||
|
ratio, status, cdate = is_session_complete(r,ps)
|
||||||
|
if ps.sessionmode == 'time':
|
||||||
|
mm.plantime += ps.sessionvalue
|
||||||
|
mm.actualtime += ps.sessionvalue*ratio
|
||||||
|
elif ps.sessionmode == 'distance':
|
||||||
|
mm.plandistance += ps.sessionvalue
|
||||||
|
mm.actualdistance += ps.sessionvalue*ratio
|
||||||
|
elif ps.sessionmode == 'rScore':
|
||||||
|
mm.planrscore += ps.sessionvalue
|
||||||
|
mm.actualrscore += ps.sessionvalue*ratio
|
||||||
|
elif ps.sessionmode == 'TRIMP':
|
||||||
|
mm.plantrimp += ps.sessionvalue
|
||||||
|
mm.actualtrimp += ps.sessionvalue*ratio
|
||||||
|
|
||||||
|
mm.save()
|
||||||
|
|
||||||
|
me.plantime += mm.plantime
|
||||||
|
me.actualtime += mm.actualtime
|
||||||
|
me.plandistance += mm.plandistance
|
||||||
|
me.actualdistance += mm.actualdistance
|
||||||
|
me.planrscore += mm.planrscore
|
||||||
|
me.actualrscore += mm.actualrscore
|
||||||
|
me.plantrimp += mm.plantrimp
|
||||||
|
me.actualtrimp += mm.actualtrimp
|
||||||
|
|
||||||
|
if me.type == 'userdefined':
|
||||||
|
me.save()
|
||||||
|
|
||||||
|
m.plantime += me.plantime
|
||||||
|
m.actualtime += me.actualtime
|
||||||
|
m.plandistance += me.plandistance
|
||||||
|
m.actualdistance += me.actualdistance
|
||||||
|
m.planrscore += me.planrscore
|
||||||
|
m.actualrscore += me.actualrscore
|
||||||
|
m.plantrimp += me.plantrimp
|
||||||
|
m.actualtrimp += me.actualtrimp
|
||||||
|
|
||||||
|
|
||||||
mesos[count2] = (me, microcycles)
|
mesos[count2] = (me, microcycles)
|
||||||
count2 += 1
|
count2 += 1
|
||||||
|
|
||||||
|
if m.type == 'userdefined':
|
||||||
|
m.save()
|
||||||
cycles[count] = (m,mesos)
|
cycles[count] = (m,mesos)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
@@ -14604,6 +14685,7 @@ class TrainingMicroCycleUpdate(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()
|
||||||
microcycle = form.save()
|
microcycle = form.save()
|
||||||
|
|
||||||
return super(TrainingMicroCycleUpdate, self).form_valid(form)
|
return super(TrainingMicroCycleUpdate, self).form_valid(form)
|
||||||
|
|
||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user