form improvements
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user