more proto
This commit is contained in:
43
rowers/templates/instantplan.html
Normal file
43
rowers/templates/instantplan.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}{{ plan.name }}{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<h1>{{ plan.name }}</h1>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_4">
|
||||||
|
<table width="100%" class="listtable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Week</th>
|
||||||
|
<th>Day</th>
|
||||||
|
<th>Workouts</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for day in trainingdays %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ day.week }}</td>
|
||||||
|
<td>{{ day.order }}</td>
|
||||||
|
<td>
|
||||||
|
{% for workout in day.workouts %}
|
||||||
|
<h3>{{ workout.workoutName }}</h3>
|
||||||
|
{{ workout|steptostring|safe }}
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_plan.html' %}
|
||||||
|
{% endblock %}
|
||||||
@@ -26,12 +26,13 @@ from rowers.rower_rules import is_coach_user, is_workout_user, isplanmember,ispr
|
|||||||
from rowers.mytypes import (
|
from rowers.mytypes import (
|
||||||
otwtypes,adaptivetypes,sexcategories,weightcategories,workouttypes,
|
otwtypes,adaptivetypes,sexcategories,weightcategories,workouttypes,
|
||||||
)
|
)
|
||||||
from rowers.utils import NoTokenError
|
from rowers.utils import NoTokenError, step_to_string
|
||||||
|
|
||||||
import rowers.payments as payments
|
import rowers.payments as payments
|
||||||
|
|
||||||
|
|
||||||
from rowers.opaque import encoder
|
from rowers.opaque import encoder
|
||||||
|
from rowers.plannedsessions import ps_dict_get_description_html
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
@@ -70,6 +71,11 @@ favanalysisicons = {
|
|||||||
'cp':'fa-user-chart',
|
'cp':'fa-user-chart',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def steptostring(steps):
|
||||||
|
res = ps_dict_get_description_html(steps)
|
||||||
|
return res
|
||||||
|
|
||||||
# for verbose version of fav analysis
|
# for verbose version of fav analysis
|
||||||
@register.filter
|
@register.filter
|
||||||
def verbose(s):
|
def verbose(s):
|
||||||
|
|||||||
@@ -741,6 +741,8 @@ urlpatterns = [
|
|||||||
re_path(r'^createplan/$',views.rower_create_trainingplan,name='rower_create_trainingplan'),
|
re_path(r'^createplan/$',views.rower_create_trainingplan,name='rower_create_trainingplan'),
|
||||||
re_path(r'^createplan/user/(?P<id>\d+)/$',views.rower_create_trainingplan,name='rower_create_trainingplan'),
|
re_path(r'^createplan/user/(?P<id>\d+)/$',views.rower_create_trainingplan,name='rower_create_trainingplan'),
|
||||||
re_path(r'^plans/$', views.rower_select_instantplan, name='rower_select_instantplan'),
|
re_path(r'^plans/$', views.rower_select_instantplan, name='rower_select_instantplan'),
|
||||||
|
re_path(r'^plans/(?P<id>[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})/$',
|
||||||
|
views.rower_view_instantplan, name='rower_view_instantplan'),
|
||||||
re_path(r'^deleteplan/(?P<pk>\d+)/$',login_required(
|
re_path(r'^deleteplan/(?P<pk>\d+)/$',login_required(
|
||||||
views.TrainingPlanDelete.as_view()),name='trainingplan_delete_view'),
|
views.TrainingPlanDelete.as_view()),name='trainingplan_delete_view'),
|
||||||
re_path(r'^deletemicrocycle/(?P<pk>\d+)/$',login_required(
|
re_path(r'^deletemicrocycle/(?P<pk>\d+)/$',login_required(
|
||||||
|
|||||||
@@ -2425,6 +2425,78 @@ class PlannedSessionDelete(DeleteView):
|
|||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
@user_passes_test(can_plan,login_url="/rowers/paidplans",
|
||||||
|
message="This functionality requires a Coach or Self-Coach plan",
|
||||||
|
redirect_field_name=None)
|
||||||
|
def rower_view_instantplan(request,id='',userid=0):
|
||||||
|
r = getrequestrower(request,userid=userid)
|
||||||
|
if not id:
|
||||||
|
raise Http404("Plan does not exist")
|
||||||
|
|
||||||
|
authorizationstring = 'Bearer '+settings.WORKOUTS_FIT_TOKEN
|
||||||
|
url = settings.WORKOUTS_FIT_URL+"/trainingplan/"+id
|
||||||
|
headers = {'Authorization':authorizationstring}
|
||||||
|
|
||||||
|
response = requests.get(url=url,headers=headers)
|
||||||
|
if response.status_code != 200:
|
||||||
|
messages.error(request,"Could not connect to the training plan server")
|
||||||
|
return HttpResponseRedirect(reverse('rower_select_instantplan'))
|
||||||
|
|
||||||
|
plan = response.json()
|
||||||
|
trainingdays = plan['plan']['trainingDays']
|
||||||
|
|
||||||
|
|
||||||
|
trainingdays2 = []
|
||||||
|
nextday = trainingdays.pop(0)
|
||||||
|
for i in range(plan['plan']['duration']):
|
||||||
|
if nextday['order'] == i+1:
|
||||||
|
nextday['week'] = (divmod(i,7)[0])+1
|
||||||
|
trainingdays2.append(nextday)
|
||||||
|
try:
|
||||||
|
nextday = trainingdays.pop(0)
|
||||||
|
except IndexError:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
trainingdays2.append(
|
||||||
|
{
|
||||||
|
'order':i+1,
|
||||||
|
'week': (divmod(i,7)[0])+1,
|
||||||
|
'workouts':[]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':reverse('plannedsessions_view'),
|
||||||
|
'name': 'Sessions'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(rower_create_trainingplan,
|
||||||
|
kwargs={'id':userid}),
|
||||||
|
'name': 'Manage Plans and Targets'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse('rower_select_instantplan'),
|
||||||
|
'name': 'Select Existing Plans'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse('rower_view_instantplan',kwargs={
|
||||||
|
'id':id,
|
||||||
|
# 'userid':userid,
|
||||||
|
}),
|
||||||
|
'name':plan['name']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return render(request,
|
||||||
|
'instantplan.html',
|
||||||
|
{
|
||||||
|
'rower':r,
|
||||||
|
'active':'nav-plan',
|
||||||
|
'plan':plan,
|
||||||
|
'trainingdays':trainingdays2,
|
||||||
|
})
|
||||||
|
|
||||||
@user_passes_test(can_plan,login_url="/rowers/paidplans",
|
@user_passes_test(can_plan,login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Coach or Self-Coach plan",
|
message="This functionality requires a Coach or Self-Coach plan",
|
||||||
redirect_field_name=None)
|
redirect_field_name=None)
|
||||||
@@ -2445,9 +2517,6 @@ def rower_select_instantplan(request,id=0):
|
|||||||
else:
|
else:
|
||||||
trainingdict = response.json()['plans']
|
trainingdict = response.json()['plans']
|
||||||
|
|
||||||
for plan in trainingdict:
|
|
||||||
print(plan['ID'],plan['name'],plan['plan']['duration'])
|
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
{
|
{
|
||||||
'url':reverse('plannedsessions_view'),
|
'url':reverse('plannedsessions_view'),
|
||||||
|
|||||||
Reference in New Issue
Block a user