Private
Public Access
1
0

Adding a notes field to the training plan

This commit is contained in:
Sander Roosendaal
2019-12-15 10:50:30 +01:00
parent d92e1968e8
commit 8e8211a8a6
3 changed files with 15 additions and 6 deletions
+4 -2
View File
@@ -1398,6 +1398,7 @@ class TrainingPlan(models.Model):
status = models.BooleanField(default=True,verbose_name='Active') status = models.BooleanField(default=True,verbose_name='Active')
target = models.ForeignKey(TrainingTarget,blank=True,null=True,on_delete=models.SET_NULL) target = models.ForeignKey(TrainingTarget,blank=True,null=True,on_delete=models.SET_NULL)
startdate = models.DateField(default=current_day) startdate = models.DateField(default=current_day)
notes = models.CharField(blank=True,null=True,max_length=200,verbose_name='Plan Notes')
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
@@ -1476,11 +1477,12 @@ class TrainingPlan(models.Model):
class TrainingPlanForm(ModelForm): class TrainingPlanForm(ModelForm):
class Meta: class Meta:
model = TrainingPlan model = TrainingPlan
fields = ['name','target','startdate','enddate','status','rowers'] fields = ['name','target','startdate','enddate','status','notes','rowers']
widgets = { widgets = {
'startdate': AdminDateWidget(), 'startdate': AdminDateWidget(),
'enddate': AdminDateWidget() 'enddate': AdminDateWidget(),
'notes': forms.Textarea()
} }
def __init__(self,*args, **kwargs): def __init__(self,*args, **kwargs):
+8 -3
View File
@@ -24,6 +24,11 @@
The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}. The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}.
{% endif %} {% endif %}
</p> </p>
<h2>Notes</h2>
<p>
{{ plan.notes }}
</p>
{% if plan|mayeditplan:request %} {% if plan|mayeditplan:request %}
<p><a href="/rowers/editplan/{{ plan.id }}">Edit the plan</a></p> <p><a href="/rowers/editplan/{{ plan.id }}">Edit the plan</a></p>
{% endif %} {% endif %}
@@ -303,7 +308,7 @@
</th> </th>
</tr> </tr>
{% if todays_date <= microcycle.enddate %} {% if todays_date <= microcycle.enddate %}
{% if microcycle.plan.type == 'userdefined' %} {% if microcycle.plan.type == 'userdefined' %}
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
@@ -381,7 +386,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="4"> <td colspan="4">
{% if microcycle|mayeditplan:request %} {% if microcycle|mayeditplan:request %}
<a href="/rowers/microcycle/{{ microcycle.id }}">edit</a> <a href="/rowers/microcycle/{{ microcycle.id }}">edit</a>
/ /
<a href="/rowers/deletemicrocycle/{{ microcycle.id }}">delete</a> <a href="/rowers/deletemicrocycle/{{ microcycle.id }}">delete</a>
@@ -427,7 +432,7 @@
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
duration is covered with non-overlapping cycles. duration is covered with non-overlapping cycles.
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>
+3 -1
View File
@@ -1557,7 +1557,7 @@ def plannedsession_totemplate_view(request,id=0):
ps.enddate = datetime.date(1970,1,1) ps.enddate = datetime.date(1970,1,1)
ps.save() ps.save()
url = reverse(plannedsession_create_view,kwargs={'userid':request.user.id}) url = reverse(plannedsession_create_view,kwargs={'userid':r.user.id})
startdatestring = startdate.strftime('%Y-%m-%d') startdatestring = startdate.strftime('%Y-%m-%d')
enddatestring = enddate.strftime('%Y-%m-%d') enddatestring = enddate.strftime('%Y-%m-%d')
@@ -2021,6 +2021,7 @@ def rower_create_trainingplan(request,userid=0):
startdate = form.cleaned_data['startdate'] startdate = form.cleaned_data['startdate']
status = form.cleaned_data['status'] status = form.cleaned_data['status']
enddate = form.cleaned_data['enddate'] enddate = form.cleaned_data['enddate']
notes = form.cleaned_data['notes']
try: try:
athletes = form.cleaned_data['rowers'] athletes = form.cleaned_data['rowers']
@@ -2033,6 +2034,7 @@ def rower_create_trainingplan(request,userid=0):
manager=themanager, manager=themanager,
startdate=startdate, startdate=startdate,
enddate=enddate,status=status, enddate=enddate,status=status,
notes=notes,
) )
p.save() p.save()