Private
Public Access
1
0

date selector works on plannedsessions

This commit is contained in:
Sander Roosendaal
2018-11-09 12:57:38 +01:00
parent a376c079c7
commit 4955ee8692
7 changed files with 194 additions and 220 deletions

View File

@@ -1040,6 +1040,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
barchart=True, otwpower=True, empower=True, inboard=inboard) barchart=True, otwpower=True, empower=True, inboard=inboard)
rscore,normp = workout_rscore(w) rscore,normp = workout_rscore(w)
trimp,hrtss = workout_trimp(w)
isbreakthrough = False isbreakthrough = False
ishard = False ishard = False

View File

@@ -853,6 +853,9 @@ def update_agegroup_db(age,sex,weightcategory,wcdurations,wcpower,
delete_agegroup_db(age,sex,weightcategory,debug=debug) delete_agegroup_db(age,sex,weightcategory,debug=debug)
wcdurations = [None if type(y) is float and np.isnan(y) else y for y in wcdurations]
wcpower = [None if type(y) is float and np.isnan(y) else y for y in wcpower]
df = pd.DataFrame( df = pd.DataFrame(
{ {
'duration':wcdurations, 'duration':wcdurations,

View File

@@ -1,3 +1,4 @@
from django.utils import timezone from django.utils import timezone
from rowers.models import Workout, PowerTimeFitnessMetric, Rower from rowers.models import Workout, PowerTimeFitnessMetric, Rower
import datetime import datetime

View File

@@ -30,6 +30,7 @@ import numpy as np
import dataprep import dataprep
import courses import courses
import iso8601 import iso8601
from iso8601 import ParseError
from rowers.tasks import handle_check_race_course from rowers.tasks import handle_check_race_course
def get_todays_micro(plan,thedate=date.today()): def get_todays_micro(plan,thedate=date.today()):
@@ -411,7 +412,7 @@ def get_dates_timeperiod(request,startdatestring='',enddatestring=''):
startdatestring = request.GET.get('startdate') startdatestring = request.GET.get('startdate')
enddatestring = request.GET.get('enddate') enddatestring = request.GET.get('enddate')
if startdate and enddate: if startdatestring and enddatestring:
startdate = dt.datetime.strptime(startdatestring,'%Y-%m-%d').date() startdate = dt.datetime.strptime(startdatestring,'%Y-%m-%d').date()
enddate = dt.datetime.strptime(enddatestring,'%Y-%m-%d').date() enddate = dt.datetime.strptime(enddatestring,'%Y-%m-%d').date()
return startdate,enddate return startdate,enddate

View File

@@ -82,62 +82,6 @@
<p>&nbsp;</p> <p>&nbsp;</p>
<ul class="cd-accordion-menu animated">
<li class="has-children" id="cycles">
<input type="checkbox" name="cycle-selector" id="cycle-selector">
<label for="cycle-selector"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;Select Time Period</label>
<ul>
<li class="has-children" id="cycles-this">
<input type="checkbox" name="cycle-this" id="cycle-this">
<label for="cycle-this">This</label>
<ul>
<li>
<a href = {{ request.path|timeurl:"thisweek" }}>
Week
</a>
</li>
<li>
<a href = {{ request.path|timeurl:"thismonth" }}>
Month
</a>
</li>
</ul>
</li>
<li class="has-children" id="cycles-next">
<input type="checkbox" name="cycle-next" id="cycle-next">
<label for="cycle-next">Next</label>
<ul>
<li>
<a href = {{ request.path|timeurl:"nextweek" }}>
Week
</a>
</li>
<li>
<a href = {{ request.path|timeurl:"nextmonth" }}>
Month
</a>
</li>
</ul>
</li>
<li class="has-children" id="cycles-Last">
<input type="checkbox" name="cycle-Last" id="cycle-Last">
<label for="cycle-Last">Last</label>
<ul>
<li>
<a href = {{ request.path|timeurl:"lastweek" }}>
Week
</a>
</li>
<li>
<a href = {{ request.path|timeurl:"lastmonth" }}>
Month
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
{% if user.is_authenticated and user|is_manager %} {% if user.is_authenticated and user|is_manager %}

View File

@@ -8,170 +8,185 @@
<h1>Planned Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1> <h1>Planned Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
{% if plannedsessions %} <ul class="main-content">
<p> <li>
Click on session name to view, edit to change the session and on the <p>
traffic light symbol to add workouts to the session <form enctype="multipart/form-data" method="get">
</p> <table>
<table width="90%" class="listtable shortpadded"> {{ dateform.as_table }}
<thead> </table>
<tr> <input type="Submit">
<th align="left">Status</th> </form>
<th align="left">On or After</th> </p>
<th align="left">On or Before</th> </li>
<th align="left">Name</th> <li class="grid_4">
<th align="left">Type</th> {% if plannedsessions %}
<th align="left">Mode</th> <p>
<th align="left">Edit</th> Click on session name to view, edit to change the session and on the
<th align="left">Planned</th> traffic light symbol to add workouts to the session
<th align="left">Actual</th> </p>
<th align="left">&nbsp;</th> <table width="90%" class="listtable shortpadded">
<th align="left">Completion Date</th> <thead>
<th align="left"> <tr>
</tr> <th align="left">Status</th>
</thead> <th align="left">On or After</th>
<tbody> <th align="left">On or Before</th>
{% for ps in plannedsessions %} <th align="left">Name</th>
<tr> <th align="left">Type</th>
<td> <th align="left">Mode</th>
{% if completeness|lookup:ps.id == 'not done' %} <th align="left">Edit</th>
{% if ps.sessiontype != 'race' %} <th align="left">Planned</th>
<a class="white dot" <th align="left">Actual</th>
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}/?when={{ timeperiod }}"> <th align="left">&nbsp;</th>
&nbsp;</a> <th align="left">Completion Date</th>
{% else %} <th align="left">
<a class="white dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a> </tr>
{% endif %} </thead>
{% elif completeness|lookup:ps.id == 'completed' %} <tbody>
{% if ps.sessiontype != 'race' %} {% for ps in plannedsessions %}
<a class="green dot" <tr>
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}/?when={{ timeperiod }}">&nbsp;</a> <td>
{% else %} {% if completeness|lookup:ps.id == 'not done' %}
<a class="green dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a> {% if ps.sessiontype != 'race' %}
{% endif %} <a class="white dot"
{% elif completeness|lookup:ps.id == 'partial' %} href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}/?when={{ timeperiod }}">
{% if ps.sessiontype != 'race' %} &nbsp;</a>
<a class="orange dot" {% else %}
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}?when={{ timeperiod }}">&nbsp;</a> <a class="white dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% else %} {% endif %}
<a class="orange dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a> {% elif completeness|lookup:ps.id == 'completed' %}
{% endif %} {% if ps.sessiontype != 'race' %}
{% else %} <a class="green dot"
{% if ps.sessiontype != 'race' %} href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}/?when={{ timeperiod }}">&nbsp;</a>
<a class="red dot" {% else %}
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}?when={{ timeperiod }}">&nbsp;</a> <a class="green dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% else %} {% endif %}
<a class="red dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a> {% elif completeness|lookup:ps.id == 'partial' %}
{% endif %} {% if ps.sessiontype != 'race' %}
{% endif %} <a class="orange dot"
</td> href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}?when={{ timeperiod }}">&nbsp;</a>
<td> {{ ps.startdate|date:"Y-m-d" }} </td> {% else %}
<td> {{ ps.enddate|date:"Y-m-d" }} </td> <a class="orange dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
<td> {% endif %}
{% if ps.sessiontype != 'race' %} {% else %}
{% if ps.name != '' %} {% if ps.sessiontype != 'race' %}
<a class="small" <a class="red dot"
href="/rowers/sessions/{{ ps.id }}/user/{{ rower.user.id }}">{{ ps.name }}</a> href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}?when={{ timeperiod }}">&nbsp;</a>
{% else %} {% else %}
<a class="small" <a class="red dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
href="/rowers/sessions/{{ ps.id }}/user/{{ rower.user.id }}">Unnamed Session</a> {% endif %}
{% endif %} {% endif %}
{% else %} </td>
{% if ps.name != '' %} <td> {{ ps.startdate|date:"Y-m-d" }} </td>
<a class="small" <td> {{ ps.enddate|date:"Y-m-d" }} </td>
href="/rowers/virtualevent/{{ ps.id }}">{{ ps.name }}</a> <td>
{% else %} {% if ps.sessiontype != 'race' %}
<a class="small" {% if ps.name != '' %}
href="/rowers/virtualevent/{{ ps.id }}">Unnamed Race</a> <a class="small"
{% endif %} href="/rowers/sessions/{{ ps.id }}/user/{{ rower.user.id }}">{{ ps.name }}</a>
{% endif %} {% else %}
</td> <a class="small"
<td> {{ ps.get_sessiontype_display }} </td> href="/rowers/sessions/{{ ps.id }}/user/{{ rower.user.id }}">Unnamed Session</a>
<td> {{ ps.get_sessionmode_display }} </td> {% endif %}
<td> {% else %}
{% if ps.manager == request.user %} {% if ps.name != '' %}
<a class="small" <a class="small"
href="/rowers/sessions/{{ ps.id }}/edit/user/{{ rower.user.id }}/?when={{ timeperiod }}">Edit</a> href="/rowers/virtualevent/{{ ps.id }}">{{ ps.name }}</a>
{% else %} {% else %}
&nbsp; <a class="small"
{% endif %} href="/rowers/virtualevent/{{ ps.id }}">Unnamed Race</a>
</td> {% endif %}
<td> {{ ps.sessionvalue }} </td> {% endif %}
<td> {{ actualvalue|lookup:ps.id }}</td> </td>
<td> {{ ps.sessionunit }} </td> <td> {{ ps.get_sessiontype_display }} </td>
{% if completeness|lookup:ps.id == 'partial' %} <td> {{ ps.get_sessionmode_display }} </td>
<td style="color:darkgray"><em> {{ completiondate|lookup:ps.id|date:"Y-m-d" }}</em></td> <td>
{% else %} {% if ps.manager == request.user %}
<td> {{ completiondate|lookup:ps.id|date:"Y-m-d" }}</td> <a class="small"
href="/rowers/sessions/{{ ps.id }}/edit/user/{{ rower.user.id }}/?when={{ timeperiod }}">Edit</a>
{% else %}
&nbsp;
{% endif %}
</td>
<td> {{ ps.sessionvalue }} </td>
<td> {{ actualvalue|lookup:ps.id }}</td>
<td> {{ ps.sessionunit }} </td>
{% if completeness|lookup:ps.id == 'partial' %}
<td style="color:darkgray"><em> {{ completiondate|lookup:ps.id|date:"Y-m-d" }}</em></td>
{% else %}
<td> {{ completiondate|lookup:ps.id|date:"Y-m-d" }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
You have no planned workouts for this period. Planned workouts are created
by your coach if you are part of a team. You can create your own
planned workouts by purchasing the "Coach" or "Self-Coach" plans.
{% endif %}
<p>
<a
href="/rowers/sessions/print/user/{{ rower.user.id }}/?when={{ timeperiod }}">
Print View</a>
</p>
</li>
<li class="grid_4">
{% if unmatchedworkouts %}
<h2>Workouts that are not linked to any session</h2>
<p>
<table width="90%" class="listtable shortpadded">
<thead>
<tr>
<th style="width:80"> Date</th>
<th align="left"> Time</th>
<th align="left"> Name</th>
<th align="left"> Type</th>
<th align="left"> Distance </th>
<th align="left"> Duration </th>
<th align="left"> Avg HR </th>
<th align="left"> Max HR </th>
</tr>
</thead>
<tbody>
{% for workout in unmatchedworkouts %}
<tr>
<td> {{ workout.date|date:"Y-m-d" }} </td>
<td> {{ workout.starttime|date:"H:i" }} </td>
{% if workout.user.user == user or user == team.manager %}
{% if workout.name != '' %}
<td>
<a href={% url rower.defaultlandingpage id=workout.id %}>
{{ workout.name }}
</a>
</td>
{% else %}
<td>
<a href={% url rower.defaultlandingpage id=workout.id %}>No Name
</a></td>
{% endif %}
{% else %}
{% if workout.name != '' %}
<td><a href="/rowers/workout/{{ workout.id }}/">{{ workout.name }}</a></td>
{% else %}
<td><a href="/rowers/workout/{{ workout.id }}/">No Name</a> </td>
{% endif %}
{% endif %}
<td> {{ workout.workouttype }} </td>
<td> {{ workout.distance }}m</td>
<td> {{ workout.duration |durationprint:"%H:%M:%S.%f" }} </td>
<td> {{ workout.averagehr }} </td>
<td> {{ workout.maxhr }} </td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %} {% endif %}
</tr> </p>
{% endfor %} </li>
</tbody> </ul>
</table>
{% else %}
You have no planned workouts for this period. Planned workouts are created
by your coach if you are part of a team. You can create your own
planned workouts by purchasing the "Coach" or "Self-Coach" plans.
{% endif %}
<p>
<a
href="/rowers/sessions/print/user/{{ rower.user.id }}/?when={{ timeperiod }}">
Print View</a>
</p>
{% if unmatchedworkouts %}
<h2>Workouts that are not linked to any session</h2>
<p>
<table width="90%" class="listtable shortpadded">
<thead>
<tr>
<th style="width:80"> Date</th>
<th align="left"> Time</th>
<th align="left"> Name</th>
<th align="left"> Type</th>
<th align="left"> Distance </th>
<th align="left"> Duration </th>
<th align="left"> Avg HR </th>
<th align="left"> Max HR </th>
</tr>
</thead>
<tbody>
{% for workout in unmatchedworkouts %}
<tr>
<td> {{ workout.date|date:"Y-m-d" }} </td>
<td> {{ workout.starttime|date:"H:i" }} </td>
{% if workout.user.user == user or user == team.manager %}
{% if workout.name != '' %}
<td>
<a href={% url rower.defaultlandingpage id=workout.id %}>
{{ workout.name }}
</a>
</td>
{% else %}
<td>
<a href={% url rower.defaultlandingpage id=workout.id %}>No Name
</a></td>
{% endif %}
{% else %}
{% if workout.name != '' %}
<td><a href="/rowers/workout/{{ workout.id }}/">{{ workout.name }}</a></td>
{% else %}
<td><a href="/rowers/workout/{{ workout.id }}/">No Name</a> </td>
{% endif %}
{% endif %}
<td> {{ workout.workouttype }} </td>
<td> {{ workout.distance }}m</td>
<td> {{ workout.duration |durationprint:"%H:%M:%S.%f" }} </td>
<td> {{ workout.averagehr }} </td>
<td> {{ workout.maxhr }} </td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</p>
{% endblock %} {% endblock %}

View File

@@ -14791,6 +14791,14 @@ def plannedsessions_view(request,
}, },
] ]
initial = {
'startdate':startdate,
'enddate':enddate,
}
dateform = DateRangeForm(initial=initial)
return render(request,'plannedsessions.html', return render(request,'plannedsessions.html',
{ {
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
@@ -14798,6 +14806,7 @@ def plannedsessions_view(request,
'plannedsessions':sps, 'plannedsessions':sps,
'plan':trainingplan, 'plan':trainingplan,
'active': 'nav-plan', 'active': 'nav-plan',
'dateform':dateform,
'rower':r, 'rower':r,
'timeperiod':timeperiod, 'timeperiod':timeperiod,
'completeness':completeness, 'completeness':completeness,