Private
Public Access
1
0

Adding very short summary on list_workouts

This commit is contained in:
Sander Roosendaal
2020-05-04 20:56:33 +02:00
parent 9874cb5ef2
commit c92505b2a0
3 changed files with 30 additions and 9 deletions

View File

@@ -59,10 +59,14 @@
<ul class="main-content">
<li class="grid_2" style="min-height:200px;">
<p>
Total meters: {{ totalmeters }}. Total time {{ totalhours }}:{{ totalminutes }}h.
<a href="/rowers/history/">Dig deeper</a>.
</p>
<script async="true" src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
{{ interactiveplot |safe }}
{{ the_div |safe }}
</li>
<li class="grid_2">
@@ -112,11 +116,11 @@
</a>
{% endif %}
{% endif %}
<span>
Page {{ workouts.number }} of {{ workouts.paginator.num_pages }}.
</span>
{% if workouts.has_next %}
{% if request.GET.q %}
<a href="{{ request.path }}?page={{ workouts.next_page_number }}&q={{ request.GET.q }}&when={{ timeperiod }}">
@@ -139,7 +143,7 @@
</p>
</li>
<li class="maxheight grid_4">
{% if workouts %}
<table width="100%" class="listtable shortpadded">
<thead>
@@ -189,7 +193,7 @@
{% else %}
<td>
<a href={% url rower.defaultlandingpage id=workout.id|encode %}>No Name
</a></td>
</a></td>
{% endif %}
{% else %}
{% if workout.name != '' %}
@@ -251,9 +255,9 @@
&nbsp;
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
@@ -277,7 +281,7 @@
{% endfor %}
{% endif %}
</ul>
{% endblock %}
{% block sidebar %}

View File

@@ -259,6 +259,18 @@ from django_mailbox.models import Message,Mailbox,MessageAttachment
from rules.contrib.views import permission_required, objectgetter
def get_totals(workouts):
totalminutes = 0
totalmeters = 0
for w in workouts:
totalmeters += w.distance
totalminutes += w.duration.hour*60+w.duration.minute
totalhour, totalminutes = divmod(totalminutes,60)
return totalmeters,totalhour, totalminutes
# creating shareable views
def allow_shares(view_func):
def sharify(request, *args, **kwargs):

View File

@@ -2009,6 +2009,8 @@ def workouts_view(request,message='',successmessage='',
g_enddate,
stack=stack)
totalmeters,totalhours, totalminutes = get_totals(g_workouts)
messages.info(request,successmessage)
messages.error(request,message)
@@ -2036,6 +2038,9 @@ def workouts_view(request,message='',successmessage='',
'interactiveplot':script,
'the_div':div,
'timeperiod':timeperiod,
'totalmeters':totalmeters,
'totalminutes':totalminutes,
'totalhours':totalhours,
})