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
+15 -5
View File
@@ -60,35 +60,45 @@ class FlexibleDecimalField(forms.DecimalField):
class InstantPlanSelectForm(forms.Form):
datechoices = (
('start date','startdate'),
('end date', 'enddate'),
('startdate','start date'),
('enddate', 'end date'),
('target','target')
)
name = forms.CharField(max_length=255,label='Plan Name',required=False)
startdate = forms.DateField(
initial=timezone.now()-datetime.timedelta(days=15),
initial=timezone.now(),
# widget=SelectDateWidget(years=range(1990,2050)),
widget=AdminDateWidget(), #format='%Y-%m-%d'),
label='Start Date')
enddate = forms.DateField(
initial=timezone.now(),
initial=timezone.now()+datetime.timedelta(days=21),
widget=AdminDateWidget(), #format='%Y-%m-%d'),
label='End Date')
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,
max_length=200,label='Course Notes',
widget=forms.Textarea)
def __init__(self, *args, **kwargs):
targets = kwargs.pop('targets',None)
instantplan = kwargs.pop('instantplan',None)
super(InstantPlanSelectForm, self).__init__(*args, **kwargs)
if targets:
targetchoices = [(x.id,x) for x in targets]
targetchoices.append((None,'---'))
self.fields['target'].choices = targetchoices
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')
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
def create_sessions_from_json(plansteps,athletes,startdate,manager):
def create_sessions_from_json(plansteps,rower,startdate,manager):
trainingdays = plansteps['trainingDays']
for day in trainingdays:
for workout in day['workouts']:
@@ -1067,8 +1067,7 @@ def create_sessions_from_json(plansteps,athletes,startdate,manager):
ps.save()
for athlete in athletes:
add_rower_session(athlete,ps)
add_rower_session(rower,ps)
def update_plannedsession(ps,cd):
for attr, value in cd.items():
+8 -4
View File
@@ -36,12 +36,16 @@
{% if form %}
<li class="grid_2">
<p>
When you submit this form, a training plan will be created based on {{ plan.name }}, ending at your target date,
and the sessions will be copied to your session calendar.
When you submit this form, a training plan will be created based on {{ plan.name }}. The sessions
will be copied to your training calendar.
</p>
<p>
You can select the end date manually or use the training target (if you have any), and the plan will start at
the date it needs to complete in time.
You can plan by when you want the plan to start or by when you want it to
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>
{% if plan.price == 0 %}
<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)
create_sessions_from_json(plansteps,[r],startdate,r.user)
create_sessions_from_json(plansteps,r,startdate,r.user)
url = reverse('plannedsessions_view')
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.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')
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:
form = InstantPlanSelectForm(targets=targets)
form = InstantPlanSelectForm(targets=targets,instantplan=plan,initial={'datechoice':'startdate'})
else:
form = None