Changeset ac3af33 in OpenWorkouts-current for ow/views/user.py
- Timestamp:
- Feb 26, 2019, 11:54:11 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 68d00f5
- Parents:
- e171dc2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/views/user.py
re171dc2 rac3af33 1 1 import json 2 from calendar import month_name3 2 from datetime import datetime, timezone, timedelta 4 3 from decimal import Decimal … … 25 24 timedelta_to_hms, 26 25 get_verification_token, 27 get_available_locale_names 26 get_gender_names, 27 get_available_locale_names, 28 get_month_names, 29 get_week_day_names 28 30 ) 29 31 from ..mail import send_verification_email 30 32 31 33 _ = TranslationStringFactory('OpenWorkouts') 34 month_name = get_month_names() 35 weekday_name = get_week_day_names() 32 36 33 37 … … 411 415 name='week') 412 416 def week_stats(context, request): 417 localizer = get_localizer(request) 413 418 stats = context.week_stats 414 419 json_stats = [] 415 420 for day in stats: 416 421 hms = timedelta_to_hms(stats[day]['time']) 422 name = localizer.translate(weekday_name[day.weekday()])[:3] 417 423 day_stats = { 418 'name': day.strftime('%a'),424 'name': name, 419 425 'time': str(hms[0]).zfill(2), 420 426 'distance': int(round(stats[day]['distance'])), … … 436 442 Return a json-encoded stream with statistics for the last 12 months 437 443 """ 444 localizer = get_localizer(request) 438 445 stats = context.yearly_stats 439 446 # this sets which month is 2 times in the stats, once this year, once … … 444 451 for month in stats: 445 452 hms = timedelta_to_hms(stats[month]['time']) 446 name = month_name[month[1]][:3]453 name = localizer.translate(month_name[month[1]])[:3] 447 454 if month[1] == repeated_month: 448 455 name += ' ' + str(month[0]) … … 473 480 in a per-week basis 474 481 """ 482 localizer = get_localizer(request) 475 483 stats = context.weekly_year_stats 476 484 # this sets which month is 2 times in the stats, once this year, once … … 481 489 for week in stats: 482 490 hms = timedelta_to_hms(stats[week]['time']) 483 name = month_name[week[1]][:3]491 name = localizer.translate(month_name[week[1]])[:3] 484 492 if week[1] == repeated_month: 485 493 name += ' ' + str(week[0])
Note: See TracChangeset
for help on using the changeset viewer.