From c92505b2a056e43526838302e092ff83ee42da6e Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 4 May 2020 20:56:33 +0200 Subject: [PATCH] Adding very short summary on list_workouts --- rowers/templates/list_workouts.html | 22 +++++++++++++--------- rowers/views/statements.py | 12 ++++++++++++ rowers/views/workoutviews.py | 5 +++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/rowers/templates/list_workouts.html b/rowers/templates/list_workouts.html index b5ec0a6e..85b00a46 100644 --- a/rowers/templates/list_workouts.html +++ b/rowers/templates/list_workouts.html @@ -59,10 +59,14 @@
  • +

    + Total meters: {{ totalmeters }}. Total time {{ totalhours }}:{{ totalminutes }}h. + Dig deeper. +

    - + {{ interactiveplot |safe }} - + {{ the_div |safe }}
  • @@ -112,11 +116,11 @@ {% endif %} {% endif %} - + Page {{ workouts.number }} of {{ workouts.paginator.num_pages }}. - + {% if workouts.has_next %} {% if request.GET.q %} @@ -139,7 +143,7 @@

  • - + {% if workouts %} @@ -189,7 +193,7 @@ {% else %} + {% endif %} {% else %} {% if workout.name != '' %} @@ -251,9 +255,9 @@   {% endif %} - + - + {% endfor %}
    No Name -
    @@ -277,7 +281,7 @@ {% endfor %} {% endif %}
- + {% endblock %} {% block sidebar %} diff --git a/rowers/views/statements.py b/rowers/views/statements.py index 18e6cd84..93a5cb17 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -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): diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index bb192e93..24e48cfd 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -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, })