completing plan implementation form
This commit is contained in:
@@ -1056,11 +1056,19 @@ def create_sessions_from_json(plansteps,athletes,startdate,manager):
|
||||
trainingdays = plansteps['trainingDays']
|
||||
for day in trainingdays:
|
||||
for workout in day['workouts']:
|
||||
print(workout['sport'])
|
||||
print(mytypes.fitmappinginv[workout['sport'].lower()])
|
||||
sessionsport = 'water'
|
||||
try:
|
||||
sessionsport = mytypes.fitmappinginv[workout['sport'].lower()]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
ps = PlannedSession(
|
||||
startdate = startdate+timedelta(days=day['order']),
|
||||
enddate = startdate,
|
||||
preferreddate = startdate,
|
||||
sessionsport = 'water', # change this
|
||||
sessionsport = sessionsport, # change this
|
||||
name = workout['workoutName'],
|
||||
steps = workout,
|
||||
manager = manager,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<h1>{{ plan.name }}</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<li class="grid_2">
|
||||
<p>Created by: {{ plan.owner.first_name }} {{ plan.owner.last_name }}</p>
|
||||
{% if plan.url %}
|
||||
<p>Link:
|
||||
@@ -23,7 +23,25 @@
|
||||
<p>{{ plan.hoursperweek }} hours per week</p>
|
||||
<p>{{ plan.sessionsperweek }} sessions per week</p>
|
||||
</li>
|
||||
<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.
|
||||
</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.
|
||||
</p>
|
||||
<form enctype="multipart/form-data" action="" method="post">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<p><input class="button" type="submit" value="Create Plan and Add Sessions"></p>
|
||||
</form>
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<h1>Plan Details</h1>
|
||||
<table width="100%" class="listtable shortpadded">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -58,23 +76,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
<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.
|
||||
</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.
|
||||
</p>
|
||||
<form enctype="multipart/form-data" action="" method="post">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<p><input class="button" type="submit" value="Create Plan and Add Sessions"></p>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -2567,6 +2567,13 @@ def rower_view_instantplan(request,id='',userid=0):
|
||||
|
||||
create_sessions_from_json(plansteps,athletes,startdate,r.user)
|
||||
|
||||
url = reverse('plannedsessions_view')
|
||||
timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d')
|
||||
url = url+'?when='+timeperiod
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
|
||||
else:
|
||||
form = TrainingPlanForm(targets=targets,initial={'status':True,'rowers':[r]},
|
||||
user=request.user)
|
||||
|
||||
Reference in New Issue
Block a user