Private
Public Access
1
0

Merge branch 'release/v15.9.8'

This commit is contained in:
Sander Roosendaal
2021-03-26 02:51:07 +01:00
5 changed files with 28 additions and 15 deletions
+13 -3
View File
@@ -66,29 +66,39 @@ class InstantPlanSelectForm(forms.Form):
) )
name = forms.CharField(max_length=255,label='Plan Name',required=False) name = forms.CharField(max_length=255,label='Plan Name',required=False)
startdate = forms.DateField( startdate = forms.DateField(
initial=timezone.now()-datetime.timedelta(days=15), initial=timezone.now(),
# widget=SelectDateWidget(years=range(1990,2050)), # widget=SelectDateWidget(years=range(1990,2050)),
widget=AdminDateWidget(), #format='%Y-%m-%d'), widget=AdminDateWidget(), #format='%Y-%m-%d'),
label='Start Date') label='Start Date')
enddate = forms.DateField( enddate = forms.DateField(
initial=timezone.now(), initial=timezone.now()+datetime.timedelta(days=21),
widget=AdminDateWidget(), #format='%Y-%m-%d'), widget=AdminDateWidget(), #format='%Y-%m-%d'),
label='End Date') label='End Date')
target = forms.ChoiceField(required=False) target = forms.ChoiceField(required=False)
datechoice = forms.ChoiceField(choices=datechoices,initial='enddate',label='Plan by target, start or end date') datechoice = forms.ChoiceField(choices=datechoices,initial='enddate',label='Plan by target, start or end date',
widget=forms.RadioSelect)
notes = forms.CharField(required=False, notes = forms.CharField(required=False,
max_length=200,label='Course Notes', max_length=200,label='Course Notes',
widget=forms.Textarea) widget=forms.Textarea)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
targets = kwargs.pop('targets',None) targets = kwargs.pop('targets',None)
instantplan = kwargs.pop('instantplan',None)
super(InstantPlanSelectForm, self).__init__(*args, **kwargs) super(InstantPlanSelectForm, self).__init__(*args, **kwargs)
if targets: if targets:
targetchoices = [(x.id,x) for x in targets] targetchoices = [(x.id,x) for x in targets]
targetchoices.append((None,'---')) targetchoices.append((None,'---'))
self.fields['target'].choices = targetchoices self.fields['target'].choices = targetchoices
else: else:
datechoices = (
('startdate','start date'),
('enddate', 'end date'),
)
self.fields['datechoice'].choices = datechoices
self.fields['datechoice'].label = 'Plan by start or end date'
self.fields.pop('target') self.fields.pop('target')
if instantplan:
self.fields['enddate'].initial = timezone.now()+datetime.timedelta(days=instantplan.duration)
+2 -3
View File
@@ -1043,7 +1043,7 @@ def get_workouts_session(r,ps):
return ws return ws
def create_sessions_from_json(plansteps,athletes,startdate,manager): def create_sessions_from_json(plansteps,rower,startdate,manager):
trainingdays = plansteps['trainingDays'] trainingdays = plansteps['trainingDays']
for day in trainingdays: for day in trainingdays:
for workout in day['workouts']: for workout in day['workouts']:
@@ -1067,8 +1067,7 @@ def create_sessions_from_json(plansteps,athletes,startdate,manager):
ps.save() ps.save()
for athlete in athletes: add_rower_session(rower,ps)
add_rower_session(athlete,ps)
def update_plannedsession(ps,cd): def update_plannedsession(ps,cd):
for attr, value in cd.items(): for attr, value in cd.items():
+8 -4
View File
@@ -36,12 +36,16 @@
{% if form %} {% if form %}
<li class="grid_2"> <li class="grid_2">
<p> <p>
When you submit this form, a training plan will be created based on {{ plan.name }}, ending at your target date, When you submit this form, a training plan will be created based on {{ plan.name }}. The sessions
and the sessions will be copied to your session calendar. will be copied to your training calendar.
</p> </p>
<p> <p>
You can select the end date manually or use the training target (if you have any), and the plan will start at You can plan by when you want the plan to start or by when you want it to
the date it needs to complete in time. be done.
</p>
<p>
If you have <a href="/rowers/createplan/">set a training target</a>, you can also ask to plan by that target. Select the
target from the targets list, and select "plan by target".
</p> </p>
{% if plan.price == 0 %} {% if plan.price == 0 %}
<form enctype="multipart/form-data" action="" method="post"> <form enctype="multipart/form-data" action="" method="post">
+1 -1
View File
@@ -225,7 +225,7 @@ def purchase_checkouts_view(request):
p.rowers.add(r) p.rowers.add(r)
create_sessions_from_json(plansteps,[r],startdate,r.user) create_sessions_from_json(plansteps,r,startdate,r.user)
url = reverse('plannedsessions_view') url = reverse('plannedsessions_view')
timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d') timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d')
+2 -2
View File
@@ -2566,7 +2566,7 @@ def rower_view_instantplan(request,id='',userid=0):
p.save() p.save()
p.rowers.add(r) p.rowers.add(r)
create_sessions_from_json(plansteps,athletes,startdate,r.user) create_sessions_from_json(plansteps,r,startdate,r.user)
url = reverse('plannedsessions_view') url = reverse('plannedsessions_view')
timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d') timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d')
@@ -2576,7 +2576,7 @@ def rower_view_instantplan(request,id='',userid=0):
elif not request.user.is_anonymous: elif not request.user.is_anonymous:
form = InstantPlanSelectForm(targets=targets) form = InstantPlanSelectForm(targets=targets,instantplan=plan,initial={'datechoice':'startdate'})
else: else:
form = None form = None