Changeset 26220ba in OpenWorkouts-current for ow/views/user.py
- Timestamp:
- Jan 25, 2019, 12:48:51 AM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- d0fc76b, ed7e9d7
- Parents:
- c6219ed (diff), 5bdfbfb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/views/user.py
rc6219ed r26220ba 1 import json 1 2 from calendar import month_name 3 from datetime import datetime 2 4 3 5 from pyramid.httpexceptions import HTTPFound … … 17 19 from ..models.root import OpenWorkouts 18 20 from ..views.renderers import OWFormRenderer 21 from ..utilities import timedelta_to_hms 19 22 20 23 _ = TranslationStringFactory('OpenWorkouts') … … 143 146 144 147 return { 148 'current_year': datetime.now().year, 149 'current_day_name': datetime.now().strftime('%a'), 145 150 'month_name': month_name, 146 151 'viewing_year': viewing_year, … … 223 228 return HTTPFound(location=request.resource_url(context, 'profile')) 224 229 return {'form': OWFormRenderer(form)} 230 231 232 @view_config( 233 context=User, 234 permission='view', 235 name='week') 236 def week_stats(context, request): 237 stats = context.week_stats 238 json_stats = [] 239 for day in stats: 240 hms = timedelta_to_hms(stats[day]['time']) 241 day_stats = { 242 'name': day.strftime('%a'), 243 'time': str(hms[0]).zfill(2), 244 'distance': int(round(stats[day]['distance'])), 245 'elevation': int(stats[day]['elevation']), 246 'workouts': stats[day]['workouts'] 247 } 248 json_stats.append(day_stats) 249 return Response(content_type='application/json', 250 charset='utf-8', 251 body=json.dumps(json_stats))
Note: See TracChangeset
for help on using the changeset viewer.