Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2019-01-14 09:28:58 +01:00
parent 8a44a84e5c
commit ca51ab7ed1
14 changed files with 382 additions and 228 deletions

View File

@@ -517,6 +517,10 @@ def course_length(course):
polygons = GeoPolygon.objects.filter(course=course).order_by("order_in_course")
totaldist = 0
if not polygons:
return 0
for i in range(len(polygons)-1):
latitude1,longitude1 = polygon_coord_center(polygons[i])
latitude2,longitude2 = polygon_coord_center(polygons[i+1])
@@ -2009,6 +2013,7 @@ class PlannedSessionForm(ModelForm):
super(PlannedSessionForm, self).__init__(*args, **kwargs)
self.fields['course'].queryset = GeoCourse.objects.all().order_by("country","name")
def get_course_timezone(course):
polygons = GeoPolygon.objects.filter(course = course)
points = GeoPoint.objects.filter(polygon = polygons[0])

View File

@@ -8,7 +8,7 @@
<h1>Create Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
<ul class="main-content">
<li>
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
@@ -18,6 +18,14 @@
</form>
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
<li class="grid_4">
<p>
On this page, you can create and edit sessions for an entire time

View File

@@ -7,17 +7,25 @@
{% block main %}
<h1>Create Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
<p>{{ timeperiod }}</p>
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
<ul class="main-content">
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
<li class="grid_2">
<h1>New Session</h1>
<form enctype="multipart/form-data" action=""

View File

@@ -7,17 +7,27 @@
{% block main %}
<h1>Edit Session</h1>
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
<ul class="main-content">
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
<li class="grid_2">
<h2>{{ thesession.name }}</h2>
{% if user.is_authenticated and user|is_manager %}

View File

@@ -19,6 +19,14 @@
</form>
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
<li class="grid_4">
{% if plannedsessions %}
<p>

View File

@@ -66,35 +66,47 @@
<h1>Clone Multiple Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
<form enctype="multipart/form-data" method="post">
<ul class="main-content">
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
<li class="grid_4">
<form enctype="multipart/form-data" method="post">
{% if plannedsessions %}
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
<table width="100%" class="listtable">
<table width="100%">
<tr>
<td>&nbsp;</td>
<td>
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
</td>
</tr>
{{ form.as_table }}
</table>
{% else %}
<p> No sessions found </p>
{% endif %}
</li>
<li class="grid_2">
<p>Select one or more planned sessions on the left,
<p>Select one or more planned sessions,
select the date when the new cycle starts below
and press submit</p>
{% csrf_token %}
@@ -106,9 +118,9 @@
</p>
<p>You can use the date and search forms above to search through all
sessions.</p>
</form>
</li>
</ul>
</form>
</ul>
{% endblock %}

View File

@@ -11,17 +11,29 @@
<h1>Coach Overview</h1>
{% endif %}
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
<li class="grid_4">
<table width="90%" class="listtable">
<table width="90%" class="listtable">
<thead>
<tr>
<th align="left">On or after</th>
@@ -70,11 +82,13 @@
</tr>
{% endfor %}
</tbody>
</table>
</table>
</li>
{% if unmatchedworkouts %}
<h1>Workouts that are not linked to any session</h1>
<table width="90%" class="listtable shortpadded">
{% if unmatchedworkouts %}
<li class="grid_4">
<h1>Workouts that are not linked to any session</h1>
<table width="90%" class="listtable shortpadded">
<thead>
<tr>
<th> Rower</th>
@@ -122,14 +136,14 @@
{% endfor %}
</tbody>
</table>
</li>
{% endif %}
</form>
</ul>
{% endblock %}
{% block sidebar %}

View File

@@ -19,36 +19,48 @@
{% block main %}
<h1>Manage Plan Execution for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
<p>Select one session on the left, and one or more workouts on the right
to match the workouts to the session. For tests and training sessions,
the selected workouts must be done on the same date. For all sessions,
the workout dates must be between the start and end date for the
session.
</p>
<p>
If you select a workout that has already been matched to another session,
it will change to match this session.
</p>
<p>
Workouts marked with a red check mark (<span style="color:red"><b>&#10004;</b></span>)
are currently linked to one of your sessions. A workout can only be assigned to
one session at a time.
</p>
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
</ul>
<form id="session_form" action="/rowers/sessions/manage/user/{{ rower.user.id }}/?when={{ timeperiod }}"
method="post">
<ul class="main-content">
<li class="grid_2">
<li class="grid_4">
<p>Select one session on the left, and one or more workouts on the right
to match the workouts to the session. For tests and training sessions,
the selected workouts must be done on the same date. For all sessions,
the workout dates must be between the start and end date for the
session.
</p>
<p>
If you select a workout that has already been matched to another session,
it will change to match this session.
</p>
<p>
Workouts marked with a red check mark (<span style="color:red"><b>&#10004;</b></span>)
are currently linked to one of your sessions. A workout can only be assigned to
one session at a time.
</p>
</li>
<li class="grid_2".
<h2>Planned Sessions</h2>
<table width="100%">
<tr>
@@ -80,9 +92,8 @@
{% csrf_token %}
<input class="button green" type="submit" value="Submit">
</li>
</ul>
</form>
{% endblock %}

View File

@@ -7,15 +7,26 @@
{% block main %}
<h1>Create Team Session</h1>
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
</ul>
<form enctype="multipart/form-data" action="" method="post">
{% if form.errors %}

View File

@@ -7,16 +7,26 @@
{% block main %}
<h1>Edit Team Session</h1>
<p>
<ul class="main-content">
<li class="grid_2">
<p>
<form enctype="multipart/form-data" method="get">
<table>
{{ dateform.as_table }}
</table>
<input type="Submit" value="Set Date Range">
</form>
</p>
</p>
</li>
<li class="grid_2">
<p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
{{ timeperiod|timedeltadays }} days</a>
</p>
<p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
{{ timeperiod|timedeltadays }} days</a>
</p>
</li>
</ul>
<form enctype="multipart/form-data" action="" method="post">
{% if form.errors %}
<p style="color: red;">
@@ -36,12 +46,16 @@
<table>
{{ teamform.as_table }}
</table></p>
</li>
<li class="grid_2">
<h1>Select Rowers</h1>
<p>
<table>
{{ rowersform.as_table }}
</table>
</p>
</li>
<li class="grid_2">
<h1>Session {{ plannedsession.name }}</h1>
<table>
{{ form.as_table }}

View File

@@ -26,6 +26,8 @@ from rowers.utils import NoTokenError
import rowers.payments as payments
import arrow
def strfdelta(tdelta):
minutes,seconds = divmod(tdelta.seconds,60)
tenths = int(tdelta.microseconds/1e5)
@@ -101,6 +103,57 @@ def durationprint(d,dstring):
else:
return d.strftime(dstring)[:-5]
def getstartenddate(timeperiod):
s,e = timeperiod.split('/')
startdate = arrow.get(s).date()
enddate = arrow.get(e).date()
return startdate,enddate
@register.filter
def nextperiodend(timeperiod):
startdate,enddate = getstartenddate(timeperiod)
timedelta = enddate-startdate
newstartdate = enddate+datetime.timedelta(days=1)
newenddate = newstartdate+timedelta
return newenddate.strftime("%Y-%m-%d")
@register.filter
def nextperiodstart(timeperiod):
startdate,enddate = getstartenddate(timeperiod)
timedelta = enddate-startdate
newstartdate = enddate+datetime.timedelta(days=1)
newenddate = newstartdate+timedelta
return newstartdate.strftime("%Y-%m-%d")
@register.filter
def previousperiodend(timeperiod):
startdate,enddate = getstartenddate(timeperiod)
timedelta = enddate-startdate
newenddate = startdate-datetime.timedelta(days=1)
newstartdate = startdate-timedelta-datetime.timedelta(days=1)
return newenddate.strftime("%Y-%m-%d")
@register.filter
def timedeltadays(timeperiod):
startdate,enddate = getstartenddate(timeperiod)
timedelta = enddate-startdate
return timedelta.days+1
@register.filter
def previousperiodstart(timeperiod):
startdate,enddate = getstartenddate(timeperiod)
timedelta = enddate-startdate
newenddate = startdate-datetime.timedelta(days=1)
newstartdate = startdate-timedelta-datetime.timedelta(days=1)
return newstartdate.strftime("%Y-%m-%d")
@register.filter
def paceprint(d):
if (d == None):

Binary file not shown.

View File

@@ -2502,7 +2502,7 @@
</Trackpoint>
</Track>
</Lap>
<Notes>&lt;Element 'Notes' at 0x137bd4e0&gt;</Notes>
<Notes>&lt;Element 'Notes' at 0x148f4cf8&gt;</Notes>
</Activity>
</Activities>
<Creator>

View File

@@ -16512,7 +16512,7 @@ def plannedsession_view(request,id=0,userid=0):
mm = Rower.objects.get(user=m)
if ps.manager != request.user:
if r.rowerplan == 'coach':
if r.rowerplan == 'coach' and r not in ps.rower.all():
teams = Team.objects.filter(manager=request.user)
members = Rower.objects.filter(team__in=teams).distinct()
teamusers = [m.user for m in members]