plannedsession_view
This commit is contained in:
@@ -1,65 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Update Planned Session{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="grid_12 alpha">
|
||||
{% include "planningbuttons.html" %}
|
||||
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<h1>Edit Session</h1>
|
||||
</div>
|
||||
<div id="timeperiod" class="grid_2 dropdown">
|
||||
<button class="grid_2 alpha button gray small dropbtn">Select Time Period ({{ timeperiod|verbosetimeperiod }})</button>
|
||||
<div class="dropdown-content">
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/today/rower/{{ rower.id }}">
|
||||
Today
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/thisweek/rower/{{ rower.id }}">
|
||||
This Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/thismonth/rower/{{ rower.id }}">
|
||||
This Month
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/lastweek/rower/{{ rower.id }}">
|
||||
Last Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/lastmonth/rower/{{ rower.id }}">
|
||||
Last Month
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/nextweek/rower/{{ rower.id }}">
|
||||
Next Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/nextmonth/rower/{{ rower.id }}">
|
||||
Next Month
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% block main %}
|
||||
<h1>Edit Session</h1>
|
||||
{% if user.is_authenticated and user|is_manager %}
|
||||
<div class="grid_2">
|
||||
<a class="button green small alpha" href="/rowers/sessions/teamedit/{{ thesession.id }}/{{ timeperiod}}">
|
||||
Assign to my Teams
|
||||
<p>
|
||||
<a href="/rowers/sessions/teamedit/{{ thesession.id }}/">
|
||||
Assign to my Teams
|
||||
</a>
|
||||
</div>
|
||||
</p>
|
||||
{% endif %}
|
||||
<div class="grid_2 omega">
|
||||
<a class="button small gray" href="/rowers/list-courses">Courses</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="right" class="grid_6 alpha">
|
||||
<h1>Plan</h1>
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<h2>Plan</h2>
|
||||
<p>
|
||||
Click on session name to view
|
||||
</p>
|
||||
@@ -93,11 +49,11 @@
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit/{{ timeperiod }}/rower/{{ rower.id }}">Edit</a>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit/user/{{ rower.user.id }}">Edit</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}/clone/{{ timeperiod }}/rower/{{ rower.id }}">Clone</a>
|
||||
href="/rowers/sessions/{{ ps.id }}/clone/user/{{ rower.user.id }}">Clone</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm">Delete</a>
|
||||
@@ -106,41 +62,42 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="grid_6 omega">
|
||||
<h1>{{ thesession.name }}</h1>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<h2>{{ thesession.name }}</h2>
|
||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
</p>
|
||||
{% csrf_token %}
|
||||
<div class="grid_1 prefix_2 alpha">
|
||||
<a class="red button small" href="/rowers/sessions/{{ thesession.id }}/deleteconfirm">Delete</a>
|
||||
<div id="id_guidance">
|
||||
|
||||
</div>
|
||||
<div class="grid_1">
|
||||
<a class="gray button small" href="/rowers/sessions/{{ thesession.id }}/clone">Clone</a>
|
||||
</div>
|
||||
<div id="formbutton" class="grid_1 suffix_1 omega">
|
||||
<input class="button green" action="/rowers/sessions/{{ thesession.id }}/edit/{{ timeperiod }}/rower/{{ rower.id }}" type="submit" value="Save">
|
||||
</div>
|
||||
<div class="grid_6" id="id_guidance">
|
||||
<p>
|
||||
<a href="/rowers/sessions/{{ thesession.id }}/deleteconfirm">Delete</a>
|
||||
<a href="/rowers/sessions/{{ thesession.id }}/clone/?when={{ timeperiod }}">Clone</a>
|
||||
</p>
|
||||
<input class="button green"
|
||||
action="/rowers/sessions/{{ thesession.id }}/edit/user/{{ rower.user.id }}" type="submit" value="Save">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_plan.html' %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block scripts %}
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
</script>
|
||||
|
||||
<h1>Clone Multiple Sessions</h1>
|
||||
<h1>Clone Multiple Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||
|
||||
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
@@ -7,158 +7,145 @@
|
||||
|
||||
{% block title %}Planned Session{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block main %}
|
||||
|
||||
<div class="grid_12 alpha">
|
||||
{% include "planningbuttons.html" %}
|
||||
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
{% if user.is_authenticated and psdict.id.1|is_session_manager:user %}
|
||||
<a class="button small gray" href="/rowers/sessions/{{ psdict.id.1 }}/edit/rower/{{ rower.id }}">
|
||||
{% if user.is_authenticated and psdict.id.1|is_session_manager:user %}
|
||||
<p>
|
||||
<a href="/rowers/sessions/{{ psdict.id.1 }}/edit/user/{{ rower.user.id }}">
|
||||
Edit Session</a>
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
{% if plannedsession.sessiontype == 'coursetest' %}
|
||||
<a class="button small gray" href="/rowers/list-courses">Courses</a>
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<h1>Session {{ psdict.name.1 }}</h1>
|
||||
<table class="listtable shortpadded" width="95%">
|
||||
{% for attr in attrs %}
|
||||
{% for key,value in psdict.items %}
|
||||
{% if key == attr %}
|
||||
<tr>
|
||||
{% if key == 'comment' %}
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1|linebreaks }}</td>
|
||||
{% else %}
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1 }}</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
<div id="right" class="grid_6 omega">
|
||||
{% if plannedsession.sessiontype == 'test' or plannedsession.sessiontype == 'coursetest' %}
|
||||
<h1>Ranking</h1>
|
||||
<table id="rankingtable" class="listtable shortpadded tablesorter" width="80%">
|
||||
<thead>
|
||||
</p>
|
||||
{% endif %}
|
||||
<h1>Session {{ psdict.name.1 }}</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<table class="listtable shortpadded" width="95%">
|
||||
{% for attr in attrs %}
|
||||
{% for key,value in psdict.items %}
|
||||
{% if key == attr %}
|
||||
<tr>
|
||||
<th>Nr</th>
|
||||
<th>Name</th>
|
||||
<th>Distance</th>
|
||||
<th>Time</th>
|
||||
<th>Date</th>
|
||||
<th>Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for result in ranking %}
|
||||
{% if result|lookup:'coursecompleted' %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ result|lookup:'name' }}</td>
|
||||
<td>{{ result|lookup:'distance' }}</td>
|
||||
<td>{{ result|lookup:'time'|deltatimeprint }}</td>
|
||||
<td>{{ result|lookup:'date'|date:"Y-m-d" }}</td>
|
||||
<td>{{ result|lookup:'type' }}</td>
|
||||
{% if key == 'comment' %}
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1|linebreaks }}</td>
|
||||
{% else %}
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1 }}</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<h1>Workouts attached</h1>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Name</th>
|
||||
<th>Distance</th>
|
||||
<th>Duration</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
{% if plannedsession.sessiontype == 'test' or plannedsession.sessiontype == 'coursetest' %}
|
||||
<h2>Ranking</h2>
|
||||
<table id="rankingtable" class="listtable shortpadded tablesorter" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nr</th>
|
||||
<th>Name</th>
|
||||
<th>Distance</th>
|
||||
<th>Time</th>
|
||||
<th>Date</th>
|
||||
<th>Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for result in ranking %}
|
||||
{% if result|lookup:'coursecompleted' %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ result|lookup:'name' }}</td>
|
||||
<td>{{ result|lookup:'distance' }}</td>
|
||||
<td>{{ result|lookup:'time'|deltatimeprint }}</td>
|
||||
<td>{{ result|lookup:'date'|date:"Y-m-d" }}</td>
|
||||
<td>{{ result|lookup:'type' }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<h1>Workouts attached</h1>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Name</th>
|
||||
<th>Distance</th>
|
||||
<th>Duration</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for workout in workouts %}
|
||||
<tr>
|
||||
<tbody>
|
||||
{% for workout in workouts %}
|
||||
<tr>
|
||||
<td> {{ workout.date|date:"Y-m-d" }} </td>
|
||||
<td>
|
||||
<div class="tooltip">
|
||||
<a href={% url manager.defaultlandingpage id=workout.id %}>
|
||||
{{ workout.name }}
|
||||
</a>
|
||||
<span class="tooltiptext">{{ workout.notes }}</span>
|
||||
<a href={% url manager.defaultlandingpage id=workout.id %}>
|
||||
{{ workout.name }}
|
||||
</a>
|
||||
<span class="tooltiptext">{{ workout.notes }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td> {{ workout.distance }}m</td>
|
||||
<td> {{ workout.duration |durationprint:"%H:%M:%S.%f" }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<h1>{{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||
<p>Status: {{ status }}</p>
|
||||
<p>Percentage complete: {{ ratio }} </p>
|
||||
</div>
|
||||
<div id="right" class="grid_6 omega">
|
||||
<h1>Stats</h1>
|
||||
<table class="listtable shortpadded" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Minutes</th>
|
||||
<th>Meters</th>
|
||||
<th>rScore</th>
|
||||
<th>TRIMP</th>
|
||||
<th>Complete Date</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for id, value in results.items %}
|
||||
<tr>
|
||||
<td>{{ value|lookup:'first_name' }} {{ value|lookup:'last_name' }}</td>
|
||||
<td>{{ value|lookup:'duration' }}</td>
|
||||
<td>{{ value|lookup:'distance' }}</td>
|
||||
<td>{{ value|lookup:'rscore' }}</td>
|
||||
<td>{{ value|lookup:'trimp' }}</td>
|
||||
<td>{{ value|lookup:'completedate' }}</td>
|
||||
<td>{{ value|lookup:'status' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="left" class="grid_6 alpha">
|
||||
{% if coursescript %}
|
||||
<h1>Course</h1>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<h2>{{ rower.user.first_name }} {{ rower.user.last_name }}</h2>
|
||||
<p>Status: {{ status }}</p>
|
||||
<p>Percentage complete: {{ ratio }} </p>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<h2>Stats</h2>
|
||||
<table class="listtable shortpadded" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Minutes</th>
|
||||
<th>Meters</th>
|
||||
<th>rScore</th>
|
||||
<th>TRIMP</th>
|
||||
<th>Complete Date</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for id, value in results.items %}
|
||||
<tr>
|
||||
<td>{{ value|lookup:'first_name' }} {{ value|lookup:'last_name' }}</td>
|
||||
<td>{{ value|lookup:'duration' }}</td>
|
||||
<td>{{ value|lookup:'distance' }}</td>
|
||||
<td>{{ value|lookup:'rscore' }}</td>
|
||||
<td>{{ value|lookup:'trimp' }}</td>
|
||||
<td>{{ value|lookup:'completedate' }}</td>
|
||||
<td>{{ value|lookup:'status' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
{% if coursescript %}
|
||||
<li class="grid_2">
|
||||
<h2>Course</h2>
|
||||
{{ coursediv|safe }}
|
||||
|
||||
|
||||
{{ coursescript|safe }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_plan.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="/static/admin/js/jquery.tablesorter.min.js"></script>
|
||||
|
||||
@@ -445,13 +445,12 @@ urlpatterns = [
|
||||
url(r'^sessions/teamcreate/$',views.plannedsession_teamcreate_view),
|
||||
url(r'^sessions/teamcreate/team/$',
|
||||
views.plannedsession_teamcreate_view),
|
||||
url(r'^sessions/teamedit/(?P<sessionid>\d+)$',views.plannedsession_teamedit_view),
|
||||
url(r'^sessions/teamedit/(?P<sessionid>\d+)/$',views.plannedsession_teamedit_view),
|
||||
url(r'^sessions/teamedit/(?P<sessionid>\d+)/user/(?P<userid>\d+)/$',views.plannedsession_teamedit_view),
|
||||
url(r'^sessions/create/$',views.plannedsession_create_view),
|
||||
url(r'^sessions/create/user/(?P<userid>\d+)$',
|
||||
views.plannedsession_create_view),
|
||||
url(r'^sessions/multiclone/$',views.plannedsession_multiclone_view),
|
||||
url(r'^sessions/multiclone/user/(?P<userid>\d+)/extra/(?P<extrasessions>\d+)$/',
|
||||
views.plannedsession_multiclone_view),
|
||||
url(r'^sessions/multiclone/user/(?P<userid>\d+)/$',
|
||||
views.plannedsession_multiclone_view),
|
||||
url(r'^sessions/multicreate/$',views.plannedsession_multicreate_view),
|
||||
@@ -460,8 +459,8 @@ urlpatterns = [
|
||||
url(r'^sessions/multicreate/user/(?P<userid>\d+)/$',
|
||||
views.plannedsession_multicreate_view),
|
||||
url(r'^sessions/(?P<id>\d+)/edit/$',views.plannedsession_edit_view),
|
||||
url(r'^sessions/(?P<id>\d+)/edit/user/(?P<userid>/$',views.plannedsession_edit_view),
|
||||
url(r'^sessions/(?P<id>\d+)/clone/user/(?P<userid>/$',views.plannedsession_clone_view),
|
||||
url(r'^sessions/(?P<id>\d+)/edit/user/(?P<userid>\d+)/$',views.plannedsession_edit_view),
|
||||
url(r'^sessions/(?P<id>\d+)/clone/user/(?P<userid>\d+)/$',views.plannedsession_clone_view),
|
||||
url(r'^sessions/(?P<id>\d+)/clone/$',views.plannedsession_clone_view),
|
||||
url(r'^sessions/(?P<id>\d+)$',views.plannedsession_view,
|
||||
name='plannedsession_view'),
|
||||
|
||||
169
rowers/views.py
169
rowers/views.py
@@ -12318,7 +12318,7 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
|
||||
# Page where user can set his details
|
||||
# Add email address to form so user can change his email address
|
||||
@login_required()
|
||||
def rower_prefs_view(request,rowerid=0,userid=0,message=""):
|
||||
def rower_prefs_view(request,userid=0,message=""):
|
||||
r = getrequestrower(request,rowerid=rowerid,userid=userid,notpermanent=True)
|
||||
|
||||
rowerid = r.id
|
||||
@@ -13598,8 +13598,8 @@ def plannedsession_multiclone_view(
|
||||
kwargs = {
|
||||
'userid':r.user.id,
|
||||
})
|
||||
|
||||
url += '?when='+when
|
||||
if when:
|
||||
url += '?when='+when
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@@ -13657,6 +13657,7 @@ def plannedsession_create_view(request,
|
||||
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
|
||||
when = request.GET.get('when')
|
||||
if when:
|
||||
timeperiod = when
|
||||
@@ -13710,7 +13711,7 @@ def plannedsession_create_view(request,
|
||||
|
||||
url = reverse(plannedsession_create_view,
|
||||
kwargs = {
|
||||
'rowerid':r.id,
|
||||
'userid':r.user.id,
|
||||
'timeperiod':timeperiod,
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
@@ -13739,6 +13740,7 @@ def plannedsession_create_view(request,
|
||||
if fprefdate > enddate:
|
||||
fprefdate = enddate
|
||||
|
||||
|
||||
forminitial = {
|
||||
'startdate':fstartdate,
|
||||
'enddate':fenddate,
|
||||
@@ -13871,10 +13873,14 @@ def plannedsession_multicreate_view(request,
|
||||
|
||||
url = reverse(plannedsession_multicreate_view,
|
||||
kwargs = {
|
||||
'rowerid':r.id,
|
||||
'timeperiod':timeperiod
|
||||
'userid':r.user.id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
if when:
|
||||
url += '?when='+when
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
ps_formset = PlannedSessionFormSet(queryset = qset,
|
||||
@@ -14009,10 +14015,17 @@ def plannedsession_teamcreate_view(request,timeperiod='thisweek',
|
||||
# Manager edits sessions for entire team
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/planmembership/",
|
||||
redirect_field_name=None)
|
||||
def plannedsession_teamedit_view(request,timeperiod='thisweek',
|
||||
sessionid=0):
|
||||
def plannedsession_teamedit_view(request,
|
||||
sessionid=0,userid=0):
|
||||
|
||||
r = getrequestrower(request)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
when = request.GET.get('when')
|
||||
if when:
|
||||
timeperiod = when
|
||||
else:
|
||||
timeperiod = 'thisweek'
|
||||
|
||||
|
||||
try:
|
||||
ps = PlannedSession.objects.get(id=sessionid)
|
||||
@@ -14103,8 +14116,11 @@ def plannedsession_teamedit_view(request,timeperiod='thisweek',
|
||||
url = reverse(plannedsession_teamedit_view,
|
||||
kwargs = {
|
||||
'sessionid':sessionid,
|
||||
'timeperiod':timeperiod,
|
||||
})
|
||||
|
||||
if when:
|
||||
url += '?when='+when
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
sessioncreateform = PlannedSessionForm(instance=ps)
|
||||
@@ -14202,9 +14218,9 @@ def plannedsessions_coach_view(request,timeperiod='thisweek',
|
||||
)
|
||||
|
||||
@login_required()
|
||||
def plannedsessions_view(request,timeperiod='thisweek',rowerid=0,userid=0):
|
||||
def plannedsessions_view(request,timeperiod='thisweek',userid=0):
|
||||
|
||||
r = getrequestrower(request,rowerid=rowerid)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
@@ -14249,9 +14265,9 @@ def plannedsessions_view(request,timeperiod='thisweek',rowerid=0,userid=0):
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def plannedsessions_print_view(request,timeperiod='thisweek',rowerid=0,userid=0):
|
||||
def plannedsessions_print_view(request,timeperiod='thisweek',userid=0):
|
||||
|
||||
r = getrequestrower(request,rowerid=rowerid)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
@@ -14282,14 +14298,14 @@ def plannedsessions_print_view(request,timeperiod='thisweek',rowerid=0,userid=0)
|
||||
|
||||
|
||||
@login_required()
|
||||
def plannedsessions_manage_view(request,timeperiod='thisweek',rowerid=0,userid=0,
|
||||
def plannedsessions_manage_view(request,timeperiod='thisweek',userid=0,
|
||||
initialsession=0):
|
||||
|
||||
is_ajax = False
|
||||
if request.is_ajax():
|
||||
is_ajax = True
|
||||
|
||||
r = getrequestrower(request,rowerid=rowerid)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
@@ -14415,10 +14431,15 @@ def plannedsessions_manage_view(request,timeperiod='thisweek',rowerid=0,userid=0
|
||||
# need clarity on cloning behavior time shift
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/planmembership/",
|
||||
redirect_field_name=None)
|
||||
def plannedsession_clone_view(request,id=0,rowerid=0,userid=0,
|
||||
timeperiod='thisweek'):
|
||||
def plannedsession_clone_view(request,id=0,userid=0):
|
||||
|
||||
r = getrequestrower(request,rowerid=rowerid)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
when = request.GET.get('when')
|
||||
if when:
|
||||
timeperiod = when
|
||||
else:
|
||||
timeperiod = 'thisweek'
|
||||
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
@@ -14460,10 +14481,12 @@ def plannedsession_clone_view(request,id=0,rowerid=0,userid=0,
|
||||
url = reverse(plannedsession_edit_view,
|
||||
kwargs = {
|
||||
'id':ps.id,
|
||||
'timeperiod':timeperiod,
|
||||
'rowerid':r.id,
|
||||
'userid':r.user.id,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
if when:
|
||||
url += '?when='+when
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@@ -14471,9 +14494,15 @@ def plannedsession_clone_view(request,id=0,rowerid=0,userid=0,
|
||||
# Edit an existing planned session
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/planmembership/",
|
||||
redirect_field_name=None)
|
||||
def plannedsession_edit_view(request,id=0,timeperiod='thisweek',rowerid=0,userid=0):
|
||||
def plannedsession_edit_view(request,id=0,userid=0):
|
||||
|
||||
r = getrequestrower(request,rowerid=rowerid)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
when = request.GET.get('when')
|
||||
if when:
|
||||
timeperiod = when
|
||||
else:
|
||||
timeperiod = 'thisweek'
|
||||
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
@@ -14493,11 +14522,10 @@ def plannedsession_edit_view(request,id=0,timeperiod='thisweek',rowerid=0,userid
|
||||
|
||||
if ps.manager != request.user:
|
||||
raise PermissionDenied("You are not allowed to edit this planned session")
|
||||
|
||||
|
||||
if ps.team.all() or len(ps.rower.all())>1:
|
||||
url = reverse(plannedsession_teamedit_view,
|
||||
kwargs={
|
||||
'timeperiod':timeperiod,
|
||||
'sessionid':id,
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
@@ -14523,20 +14551,57 @@ def plannedsession_edit_view(request,id=0,timeperiod='thisweek',rowerid=0,userid
|
||||
url = reverse(plannedsession_edit_view,
|
||||
kwargs={
|
||||
'id':int(ps.id),
|
||||
'timeperiod':timeperiod,
|
||||
'rowerid':r.id,
|
||||
'userid':r.user.id,
|
||||
})
|
||||
|
||||
if when:
|
||||
url += '?when='+when
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
sessioncreateform = PlannedSessionForm(instance=ps)
|
||||
|
||||
sps = get_sessions(r,startdate=startdate,enddate=enddate)
|
||||
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':reverse(plannedsessions_view,
|
||||
kwargs={'userid':userid}),
|
||||
'name': 'Plan'
|
||||
},
|
||||
{
|
||||
'url': reverse(plannedsessions_view,
|
||||
kwargs={'userid':userid}),
|
||||
'name': 'Sessions'
|
||||
},
|
||||
{
|
||||
'url':reverse(plannedsession_view,
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
'id':id,
|
||||
}
|
||||
),
|
||||
'name': ps.id
|
||||
},
|
||||
{
|
||||
'url':reverse(plannedsession_edit_view,
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
'id':id,
|
||||
}
|
||||
),
|
||||
'name': 'Edit'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
return render(request,'plannedsessionedit.html',
|
||||
{
|
||||
'teams':get_my_teams(request.user),
|
||||
'plan':trainingplan,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'form':sessioncreateform,
|
||||
'active':'nav-plan',
|
||||
'plannedsessions':sps,
|
||||
'thesession':ps,
|
||||
'rower':r,
|
||||
@@ -14546,16 +14611,16 @@ def plannedsession_edit_view(request,id=0,timeperiod='thisweek',rowerid=0,userid
|
||||
|
||||
|
||||
@login_required()
|
||||
def plannedsession_view(request,id=0,rowerid=0,userid=0,
|
||||
timeperiod='thisweek'):
|
||||
def plannedsession_view(request,id=0,userid=0):
|
||||
|
||||
m = getrower(request.user)
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
|
||||
if not rowerid:
|
||||
r = m
|
||||
when = request.GET.get('when')
|
||||
if when:
|
||||
timeperiod = when
|
||||
else:
|
||||
r = Rower.objects.get(id=rowerid)
|
||||
timeperiod = 'thisweek'
|
||||
|
||||
|
||||
try:
|
||||
ps = PlannedSession.objects.get(id=id)
|
||||
@@ -14569,6 +14634,8 @@ def plannedsession_view(request,id=0,rowerid=0,userid=0,
|
||||
coursescript = ''
|
||||
coursediv = ''
|
||||
|
||||
m = ps.manager
|
||||
|
||||
if ps.manager != request.user:
|
||||
if r.rowerplan == 'coach':
|
||||
teams = Team.objects.filter(manager=request.user)
|
||||
@@ -14668,6 +14735,30 @@ def plannedsession_view(request,id=0,rowerid=0,userid=0,
|
||||
enddate__gte = enddate)[0]
|
||||
except IndexError:
|
||||
trainingplan = None
|
||||
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':reverse(plannedsessions_view,
|
||||
kwargs={'userid':userid}),
|
||||
'name': 'Plan'
|
||||
},
|
||||
{
|
||||
'url': reverse(plannedsessions_view,
|
||||
kwargs={'userid':userid}),
|
||||
'name': 'Sessions'
|
||||
},
|
||||
{
|
||||
'url':reverse(plannedsession_view,
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
'id':id,
|
||||
}
|
||||
),
|
||||
'name': ps.id
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
return render(request,'plannedsessionview.html',
|
||||
{
|
||||
@@ -14679,6 +14770,8 @@ def plannedsession_view(request,id=0,rowerid=0,userid=0,
|
||||
'sessionvalue','sessionunit','comment',
|
||||
],
|
||||
'workouts': ws,
|
||||
'active':'nav-plan',
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'manager':m,
|
||||
'rower':r,
|
||||
'ratio':ratio,
|
||||
@@ -15106,7 +15199,7 @@ def virtualevent_addboat_view(request,id=0):
|
||||
{
|
||||
'form':form,
|
||||
'race':race,
|
||||
'rowerid':r.id,
|
||||
'userid':r.user.id,
|
||||
'active': 'nav-racing',
|
||||
})
|
||||
|
||||
@@ -15199,7 +15292,7 @@ def virtualevent_register_view(request,id=0):
|
||||
{
|
||||
'form':form,
|
||||
'race':race,
|
||||
'rowerid':r.id,
|
||||
'userid':r.user.id,
|
||||
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user