Private
Public Access
1
0

template library

This commit is contained in:
Sander Roosendaal
2021-03-05 08:57:37 +01:00
parent 8112f8322a
commit b107ea3a50
5 changed files with 128 additions and 1 deletions

View File

@@ -2316,6 +2316,7 @@ class PlannedSession(models.Model):
hasranking = models.BooleanField(default=False)
is_template = models.BooleanField(default=False)
is_public = models.BooleanField(default=False)
fitfile = models.FileField(upload_to=get_file_path,blank=True,null=True)
#steps_json = models.TextField(max_length=10000,default=None,blank=True,null=True)

View File

@@ -100,6 +100,14 @@
{% endif %}
</ul><!-- cd-accordion-menu -->
<ul class="cd-accordion-menu animated">
<li id="library">
<a href="/rowers/sessions/library/">
<i class="fas fa-books fa-fw"></i>&nbsp;Session Library
</a>
</li>
</ul>
<p>&nbsp;</p>
{% if user.is_authenticated and user|is_planmember %}
@@ -117,7 +125,7 @@
{% if member == rower.user%}
&bull;
{% else %}
&nbsp;
&nbsp;
{% endif %}
{{ member.first_name }} {{ member.last_name }}
</a>

View File

@@ -0,0 +1,67 @@
{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block title %}Planned Sessions{% endblock %}
{% block main %}
<h1>Planned Session Library</h1>
<ul class="main-content">
<li class="grid_4">
{% if templates %}
<p>
Click on session name to view, edit to change the session.
</p>
<table width="90%" class="listtable shortpadded">
<thead>
<tr>
<th align="left">Name</th>
<th align="left">Type</th>
<th align="left">Mode</th>
<th align="left">Edit</th>
<th align="left">
</tr>
</thead>
<tbody>
{% for ps in templates %}
<tr>
<td>
{% if ps.name != '' %}
<a class="small"
href="/rowers/sessions/{{ ps.id }}/clone/user/{{ rower.user.id }}">{{ ps.name }}</a>
{% else %}
<a class="small"
href="/rowers/sessions/{{ ps.id }}/clone/user/{{ rower.user.id }}">Unnamed Session</a>
{% endif %}
</td>
<td> {{ ps.get_sessiontype_display }} </td>
<td> {{ ps.get_sessionmode_display }} </td>
<td>
<a class="small"
href="/rowers/sessions/{{ ps.id }}/templateedit/user/{{ rower.user.id }}">
<i class="fas fa-pencil-alt fa-fw"></i>
</a>
</td>
<td> {{ ps.sessionvalue }} </td>
<td> {{ ps.sessionunit }} </td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
You have no sessions in your Library yet.
{% endif %}
</li>
</ul>
{% endblock %}
{% block sidebar %}
{% include 'menu_plan.html' %}
{% endblock %}

View File

@@ -793,6 +793,7 @@ urlpatterns = [
name='trainingtarget_update_view'),
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/test\_strokedata/$',views.strokedataform),
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/v2/test\_strokedata/$',views.strokedataform_v2),
re_path(r'^sessions/library/$',views.template_library_view,name="template_library_view"),
re_path(r'^sessions/teamcreate/user/(?P<userid>\d+)/$',views.plannedsession_teamcreate_view,
name='plannedsession_teamcreate_view'),
re_path(r'^sessions/teamcreate/team/(?P<teamid>\d+)/user/(?P<userid>\d+)/$',

View File

@@ -412,6 +412,48 @@ def plannedsession_multiclone_view(
}
)
# Manage Template sessions (library)
@user_passes_test(can_plan,login_url="/rowers/paidplans/",
message="This functionality requires a Coach or Self-Coach plan",
redirect_field_name=None)
def template_library_view(request,userid=0):
r = getrequestplanrower(request,userid=userid)
templates = PlannedSession.objects.filter(manager=request.user,is_template=True)
startdate,enddate = get_dates_timeperiod(request)
try:
trainingplan = TrainingPlan.objects.filter(
startdate__lte = startdate,
rowers = r,
enddate__gte = enddate)[0]
except IndexError:
trainingplan = None
breadcrumbs = [
{
'url': reverse(plannedsessions_view),
'name': 'Planned Sessions'
},
{
'url': reverse(template_library_view),
'name': 'Session Library',
}
]
return render(request,'templatelibrary.html',
{
'teams':get_my_teams(request.user),
'breadcrumbs': breadcrumbs,
'templates':templates,
'plan': trainingplan,
'rower':r,
'active':'nav-plan',
}
)
# Individual user creates training for himself
@user_passes_test(can_plan,login_url="/rowers/paidplans/",
message="This functionality requires a Coach or Self-Coach plan",
@@ -511,6 +553,14 @@ def plannedsession_create_view(request,
manager=request.user,
is_template=True).order_by("name")
sessiontemplates2 = PlannedSession.objects.filter(
is_template=True,is_public=True
).order_by("name")
sessiontemplates = sessiontemplates | sessiontemplates2
sessiontemplates = sessiontemplates.order_by("name")
tag = request.GET.get('tag')
if tag:
tags = [tag]