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']
|
trainingdays = plansteps['trainingDays']
|
||||||
for day in trainingdays:
|
for day in trainingdays:
|
||||||
for workout in day['workouts']:
|
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(
|
ps = PlannedSession(
|
||||||
startdate = startdate+timedelta(days=day['order']),
|
startdate = startdate+timedelta(days=day['order']),
|
||||||
enddate = startdate,
|
enddate = startdate,
|
||||||
preferreddate = startdate,
|
preferreddate = startdate,
|
||||||
sessionsport = 'water', # change this
|
sessionsport = sessionsport, # change this
|
||||||
name = workout['workoutName'],
|
name = workout['workoutName'],
|
||||||
steps = workout,
|
steps = workout,
|
||||||
manager = manager,
|
manager = manager,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<h1>{{ plan.name }}</h1>
|
<h1>{{ plan.name }}</h1>
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
<li class="grid_4">
|
<li class="grid_2">
|
||||||
<p>Created by: {{ plan.owner.first_name }} {{ plan.owner.last_name }}</p>
|
<p>Created by: {{ plan.owner.first_name }} {{ plan.owner.last_name }}</p>
|
||||||
{% if plan.url %}
|
{% if plan.url %}
|
||||||
<p>Link:
|
<p>Link:
|
||||||
@@ -23,7 +23,25 @@
|
|||||||
<p>{{ plan.hoursperweek }} hours per week</p>
|
<p>{{ plan.hoursperweek }} hours per week</p>
|
||||||
<p>{{ plan.sessionsperweek }} sessions per week</p>
|
<p>{{ plan.sessionsperweek }} sessions per week</p>
|
||||||
</li>
|
</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">
|
<li class="grid_4">
|
||||||
|
<h1>Plan Details</h1>
|
||||||
<table width="100%" class="listtable shortpadded">
|
<table width="100%" class="listtable shortpadded">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -58,23 +76,6 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</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>
|
</ul>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -2567,6 +2567,13 @@ def rower_view_instantplan(request,id='',userid=0):
|
|||||||
|
|
||||||
create_sessions_from_json(plansteps,athletes,startdate,r.user)
|
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:
|
else:
|
||||||
form = TrainingPlanForm(targets=targets,initial={'status':True,'rowers':[r]},
|
form = TrainingPlanForm(targets=targets,initial={'status':True,'rowers':[r]},
|
||||||
user=request.user)
|
user=request.user)
|
||||||
|
|||||||
Reference in New Issue
Block a user