Changeset a3c3baa in OpenWorkouts-current
- Timestamp:
- Feb 6, 2019, 1:25:07 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 978575d
- Parents:
- 40ee398
- Location:
- ow
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/templates/profile.pt
r40ee398 ra3c3baa 51 51 <div class="workout-list"> 52 52 <div class="total-workouts"> 53 <tal:w tal:replace="context.num_workouts"></tal:w> 54 <tal:t i18n:translate="">workouts</tal:t> 53 <span> 54 <tal:w tal:replace="len(workouts)"></tal:w> 55 <tal:t i18n:translate="">workouts</tal:t> 56 </span> 57 <span> 58 <tal:hms tal:define="hms timedelta_to_hms(totals['time'])"> 59 <tal:h tal:content="str(hms[0]).zfill(2)"></tal:h> 60 <tal:t i18n:translate="">hours</tal:t>, 61 <tal:h tal:content="str(hms[1]).zfill(2)"></tal:h> 62 <tal:t i18n:translate="">min.</tal:t> 63 </tal:hms> 64 </span> 65 <span> 66 <tal:w tal:replace="round(totals['distance'])"></tal:w> 67 <tal:t i18n:translate="">km</tal:t> 68 </span> 69 <span> 70 <tal:w tal:replace="round(totals['elevation'])"></tal:w> 71 <tal:t i18n:translate="">m</tal:t> 72 </span> 55 73 </div> 56 74 -
ow/views/user.py
r40ee398 ra3c3baa 1 1 import json 2 2 from calendar import month_name 3 from datetime import datetime, timezone 3 from datetime import datetime, timezone, timedelta 4 from decimal import Decimal 4 5 5 6 from pyramid.httpexceptions import HTTPFound … … 169 170 month = int(request.GET.get('month', now.month)) 170 171 week = request.GET.get('week', None) 172 workouts = context.workouts(year, month, week) 173 totals = { 174 'distance': Decimal(0), 175 'time': timedelta(0), 176 'elevation': Decimal(0) 177 } 178 179 for workout in workouts: 180 totals['distance'] += getattr(workout, 'distance', Decimal(0)) 181 totals['time'] += getattr(workout, 'duration', timedelta(0)) 182 totals['elevation'] += getattr(workout, 'uphill', Decimal(0)) 183 171 184 return { 172 'workouts': context.workouts(year, month, week),185 'workouts': workouts, 173 186 'current_month': '{year}-{month}'.format( 174 187 year=str(year), month=str(month).zfill(2)), 175 'current_week': week 188 'current_week': week, 189 'totals': totals 176 190 } 177 191
Note: See TracChangeset
for help on using the changeset viewer.