Merge branch 'release/v15.9.7'
This commit is contained in:
@@ -58,6 +58,40 @@ class FlexibleDecimalField(forms.DecimalField):
|
|||||||
value = value.replace('.', '').replace(',', '.')
|
value = value.replace('.', '').replace(',', '.')
|
||||||
return super(FlexibleDecimalField, self).to_python(value)
|
return super(FlexibleDecimalField, self).to_python(value)
|
||||||
|
|
||||||
|
class InstantPlanSelectForm(forms.Form):
|
||||||
|
datechoices = (
|
||||||
|
('start date','startdate'),
|
||||||
|
('end date', 'enddate'),
|
||||||
|
('target','target')
|
||||||
|
)
|
||||||
|
name = forms.CharField(max_length=255,label='Plan Name',required=False)
|
||||||
|
startdate = forms.DateField(
|
||||||
|
initial=timezone.now()-datetime.timedelta(days=15),
|
||||||
|
# widget=SelectDateWidget(years=range(1990,2050)),
|
||||||
|
widget=AdminDateWidget(), #format='%Y-%m-%d'),
|
||||||
|
label='Start Date')
|
||||||
|
enddate = forms.DateField(
|
||||||
|
initial=timezone.now(),
|
||||||
|
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')
|
||||||
|
notes = forms.CharField(required=False,
|
||||||
|
max_length=200,label='Course Notes',
|
||||||
|
widget=forms.Textarea)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
targets = kwargs.pop('targets',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:
|
||||||
|
self.fields.pop('target')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Video Analysis creation form
|
# Video Analysis creation form
|
||||||
class VideoAnalysisCreateForm(forms.Form):
|
class VideoAnalysisCreateForm(forms.Form):
|
||||||
name = forms.CharField(max_length=255,label='Analysis Name',required=False)
|
name = forms.CharField(max_length=255,label='Analysis Name',required=False)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
<p>Price: {{ plan.price }}€</p>
|
<p>Price: {{ plan.price }}€</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
|
{% 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 }}, ending at your target date,
|
||||||
@@ -58,6 +59,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>
|
||||||
|
<a href="/login/?next={{ request.get_full_path }}">Log in</a> to install this plan to your training calendar.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
<h1>Plan Details</h1>
|
<h1>Plan Details</h1>
|
||||||
<table width="100%" class="listtable shortpadded">
|
<table width="100%" class="listtable shortpadded">
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ def buy_trainingplan_view(request,id=0):
|
|||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
billingaddressform = RowerBillingAddressForm(instance=r)
|
billingaddressform = RowerBillingAddressForm(instance=r)
|
||||||
form = TrainingPlanForm(request.POST,user=request.user)
|
form = InstantPlanSelectForm(request.POST)
|
||||||
if billingaddressform.is_valid():
|
if billingaddressform.is_valid():
|
||||||
cd = billingaddressform.cleaned_data
|
cd = billingaddressform.cleaned_data
|
||||||
for attr, value in cd.items():
|
for attr, value in cd.items():
|
||||||
@@ -121,8 +121,10 @@ def buy_trainingplan_view(request,id=0):
|
|||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
|
|
||||||
enddate = cd['enddate']
|
enddate = cd['enddate']
|
||||||
|
startdate = cd['startdate']
|
||||||
notes = cd['notes']
|
notes = cd['notes']
|
||||||
status = cd['status']
|
datechoice = form.cleaned_data['datechoice']
|
||||||
|
status = True
|
||||||
|
|
||||||
# get target and set enddate
|
# get target and set enddate
|
||||||
try:
|
try:
|
||||||
@@ -138,8 +140,12 @@ def buy_trainingplan_view(request,id=0):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
target = None
|
target = None
|
||||||
|
|
||||||
if target:
|
if target and datechoice == 'target':
|
||||||
enddate = target.date
|
enddate = target.date
|
||||||
|
elif datechoice == 'startdate':
|
||||||
|
enddate = startdate+datetime.timedelta(days=plan.duration)
|
||||||
|
else:
|
||||||
|
startdate = enddate-datetime.timedelta(days=plan.duration)
|
||||||
|
|
||||||
pars = {
|
pars = {
|
||||||
'name':cd['name'],
|
'name':cd['name'],
|
||||||
@@ -154,7 +160,7 @@ def buy_trainingplan_view(request,id=0):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = TrainingPlanForm(user=request.user)
|
form = InstantPlanForm()
|
||||||
billingaddressform = RowerBillingAddressForm(instance=r)
|
billingaddressform = RowerBillingAddressForm(instance=r)
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
@@ -243,6 +249,9 @@ def purchase_checkouts_view(request):
|
|||||||
url = reverse("purchase_checkouts_view")
|
url = reverse("purchase_checkouts_view")
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
url = reverse('rower_select_instantplan')
|
||||||
|
if 'plan' in request.POST:
|
||||||
|
plan = plan = InstantPlan.objects.get(id=request.POST['plan'])
|
||||||
url = reverse('rower_view_instantplan',kwargs={
|
url = reverse('rower_view_instantplan',kwargs={
|
||||||
'id':plan.uuid,
|
'id':plan.uuid,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2517,14 +2517,15 @@ def rower_view_instantplan(request,id='',userid=0):
|
|||||||
date__gte=datetime.date.today(),
|
date__gte=datetime.date.today(),
|
||||||
).order_by("-date")
|
).order_by("-date")
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST' and not request.user.is_anonymous:
|
||||||
if not can_plan(request.user):
|
if not can_plan(request.user):
|
||||||
messages.error(request,'You must be on a <a href="/rowers/paidplans">paid plan</a> to use this functionality')
|
messages.error(request,'You must be on a <a href="/rowers/paidplans">paid plan</a> to use this functionality')
|
||||||
url = reverse('rower_view_instantplan',kwargs={
|
url = reverse('rower_view_instantplan',kwargs={
|
||||||
'id':id,
|
'id':id,
|
||||||
})
|
})
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
form = TrainingPlanForm(request.POST,user=request.user)
|
form = InstantPlanSelectForm(request.POST)
|
||||||
|
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
plansteps = response.json()
|
plansteps = response.json()
|
||||||
@@ -2541,17 +2542,17 @@ def rower_view_instantplan(request,id='',userid=0):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
target = None
|
target = None
|
||||||
enddate = form.cleaned_data['enddate']
|
enddate = form.cleaned_data['enddate']
|
||||||
|
startdate = form.cleaned_data['startdate']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
status = form.cleaned_data['status']
|
datechoice = form.cleaned_data['datechoice']
|
||||||
if target:
|
status = True
|
||||||
|
if target and datechoice == 'target':
|
||||||
enddate = target.date
|
enddate = target.date
|
||||||
|
elif datechoice == 'startdate':
|
||||||
|
enddate = startdate+datetime.timedelta(days=plan.duration)
|
||||||
|
else:
|
||||||
|
startdate = enddate-datetime.timedelta(days=plan.duration)
|
||||||
|
|
||||||
startdate = enddate-datetime.timedelta(days=plan.duration+1)
|
|
||||||
|
|
||||||
try:
|
|
||||||
athletes = form.cleaned_data['rowers']
|
|
||||||
except KeyError:
|
|
||||||
athletes = [r]
|
|
||||||
|
|
||||||
p = TrainingPlan(
|
p = TrainingPlan(
|
||||||
name=name,
|
name=name,
|
||||||
@@ -2563,10 +2564,7 @@ def rower_view_instantplan(request,id='',userid=0):
|
|||||||
)
|
)
|
||||||
|
|
||||||
p.save()
|
p.save()
|
||||||
|
p.rowers.add(r)
|
||||||
for athlete in athletes:
|
|
||||||
if can_plan_user(request.user,athlete):
|
|
||||||
p.rowers.add(athlete)
|
|
||||||
|
|
||||||
create_sessions_from_json(plansteps,athletes,startdate,r.user)
|
create_sessions_from_json(plansteps,athletes,startdate,r.user)
|
||||||
|
|
||||||
@@ -2577,9 +2575,10 @@ def rower_view_instantplan(request,id='',userid=0):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
|
elif not request.user.is_anonymous:
|
||||||
|
form = InstantPlanSelectForm(targets=targets)
|
||||||
else:
|
else:
|
||||||
form = TrainingPlanForm(targets=targets,initial={'status':True,'rowers':[r]},
|
form = None
|
||||||
user=request.user)
|
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ from rowers.forms import (
|
|||||||
VideoAnalysisCreateForm,WorkoutSingleSelectForm,
|
VideoAnalysisCreateForm,WorkoutSingleSelectForm,
|
||||||
VideoAnalysisMetricsForm,SurveyForm,HistorySelectForm,
|
VideoAnalysisMetricsForm,SurveyForm,HistorySelectForm,
|
||||||
StravaChartForm,FitnessFitForm,PerformanceManagerForm,
|
StravaChartForm,FitnessFitForm,PerformanceManagerForm,
|
||||||
TrainingPlanBillingForm,
|
TrainingPlanBillingForm,InstantPlanSelectForm
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
|
|||||||
Reference in New Issue
Block a user