added other rowers result to session view
This commit is contained in:
@@ -71,6 +71,51 @@ def timefield_to_seconds_duration(t):
|
|||||||
|
|
||||||
return duration
|
return duration
|
||||||
|
|
||||||
|
def get_session_metrics(ps):
|
||||||
|
rowers = ps.rower.all()
|
||||||
|
rscore = []
|
||||||
|
trimp = []
|
||||||
|
duration = []
|
||||||
|
distance = []
|
||||||
|
firstname = []
|
||||||
|
lastname = []
|
||||||
|
|
||||||
|
for r in rowers:
|
||||||
|
rscorev = 0
|
||||||
|
trimpv = 0
|
||||||
|
durationv = 0
|
||||||
|
distancev = 0
|
||||||
|
|
||||||
|
|
||||||
|
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
||||||
|
if len(ws) != 0:
|
||||||
|
for w in ws:
|
||||||
|
distancev += w.distance
|
||||||
|
durationv += timefield_to_seconds_duration(w.duration)
|
||||||
|
trimpv += dataprep.workout_trimp(w)
|
||||||
|
rscorev += dataprep.workout_rscore(w)
|
||||||
|
|
||||||
|
|
||||||
|
durationv /= 60.
|
||||||
|
|
||||||
|
trimp.append(int(trimpv))
|
||||||
|
duration.append(int(durationv))
|
||||||
|
distance.append(int(distancev))
|
||||||
|
rscore.append(int(rscorev))
|
||||||
|
firstname.append(r.user.first_name)
|
||||||
|
lastname.append(r.user.last_name)
|
||||||
|
|
||||||
|
thedict = {
|
||||||
|
'first_name':firstname,
|
||||||
|
'last_name':lastname,
|
||||||
|
'duration':duration,
|
||||||
|
'distance':distance,
|
||||||
|
'rscore':rscore,
|
||||||
|
'trimp':trimp
|
||||||
|
}
|
||||||
|
|
||||||
|
return thedict
|
||||||
|
|
||||||
def is_session_complete(r,ps):
|
def is_session_complete(r,ps):
|
||||||
status = 'not done'
|
status = 'not done'
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
{% include "planningbuttons.html" %}
|
{% include "planningbuttons.html" %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
<div id="left" class="grid_6 alpha">
|
<div id="left" class="grid_6 alpha">
|
||||||
<h1>Session {{ psdict.name.1 }}</h1>
|
<h1>Session {{ psdict.name.1 }}</h1>
|
||||||
<table class="listtable shortpadded" width="80%">
|
<table class="listtable shortpadded" width="80%">
|
||||||
@@ -22,9 +23,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<h1>Result</h1>
|
|
||||||
<p>Status: {{ status }}</p>
|
|
||||||
<p>Percentage complete: {{ ratio }} </p>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="right" class="grid_6 omega">
|
<div id="right" class="grid_6 omega">
|
||||||
<h1>Workouts attached</h1>
|
<h1>Workouts attached</h1>
|
||||||
@@ -53,7 +51,38 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
<div id="left" class="grid_6 alpha">
|
||||||
|
<h1>Result</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="80%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Minutes</th>
|
||||||
|
<th>Meters</th>
|
||||||
|
<th>rScore</th>
|
||||||
|
<th>TRIMP</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>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -12162,6 +12162,7 @@ def plannedsession_view(request,id=0,rowerid=0):
|
|||||||
|
|
||||||
m = getrower(request.user)
|
m = getrower(request.user)
|
||||||
|
|
||||||
|
|
||||||
if not rowerid:
|
if not rowerid:
|
||||||
r = m
|
r = m
|
||||||
else:
|
else:
|
||||||
@@ -12176,6 +12177,8 @@ def plannedsession_view(request,id=0,rowerid=0):
|
|||||||
if ps.manager != request.user and r not in ps.rower.all():
|
if ps.manager != request.user and r not in ps.rower.all():
|
||||||
raise PermissionDenied("You do not have access to this session")
|
raise PermissionDenied("You do not have access to this session")
|
||||||
|
|
||||||
|
resultsdict = get_session_metrics(ps)
|
||||||
|
resultsdict = pd.DataFrame(resultsdict).transpose().to_dict()
|
||||||
|
|
||||||
psdict = my_dict_from_instance(ps,PlannedSession)
|
psdict = my_dict_from_instance(ps,PlannedSession)
|
||||||
|
|
||||||
@@ -12196,7 +12199,8 @@ def plannedsession_view(request,id=0,rowerid=0):
|
|||||||
'manager':m,
|
'manager':m,
|
||||||
'rower':r,
|
'rower':r,
|
||||||
'ratio':ratio,
|
'ratio':ratio,
|
||||||
'status':status
|
'status':status,
|
||||||
|
'results':resultsdict,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user