Changeset a3c3baa in OpenWorkouts-current for ow/views/user.py
- Timestamp:
- Feb 6, 2019, 1:25:07 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 978575d
- Parents:
- 40ee398
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.