Changes in ow/views/user.py [6dc1846:5bdfbfb] in OpenWorkouts-current


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/views/user.py

    r6dc1846 r5bdfbfb  
    11import json
    22from calendar import month_name
    3 from datetime import datetime, timezone
     3from datetime import datetime
    44
    55from pyramid.httpexceptions import HTTPFound
     
    146146
    147147    return {
    148         'current_year': datetime.now(timezone.utc).year,
    149         'current_day_name': datetime.now(timezone.utc).strftime('%a'),
     148        'current_year': datetime.now().year,
     149        'current_day_name': datetime.now().strftime('%a'),
    150150        'month_name': month_name,
    151151        'viewing_year': viewing_year,
     
    165165    basic info, stats, etc
    166166    """
    167     now = datetime.now(timezone.utc)
    168     return {
    169         'current_month': now.strftime('%Y-%m')
    170     }
     167    return {}
    171168
    172169
     
    253250                    charset='utf-8',
    254251                    body=json.dumps(json_stats))
    255 
    256 
    257 @view_config(
    258     context=User,
    259     permission='view',
    260     name='yearly')
    261 def last_months_stats(context, request):
    262     """
    263     Return a json-encoded stream with statistics for the last 12 months
    264     """
    265     stats = context.yearly_stats
    266     # this sets which month is 2 times in the stats, once this year, once
    267     # the previous year. We will show it a bit different in the UI (showing
    268     # the year too to prevent confusion)
    269     repeated_month = datetime.now(timezone.utc).date().month
    270     json_stats = []
    271     for month in stats:
    272         hms = timedelta_to_hms(stats[month]['time'])
    273         name = month_name[month[1]][:3]
    274         if month[1] == repeated_month:
    275             name += ' ' + str(month[0])
    276         month_stats = {
    277             'id': str(month[0]) + '-' + str(month[1]).zfill(2),
    278             'name': name,
    279             'time': str(hms[0]).zfill(2),
    280             'distance': int(round(stats[month]['distance'])),
    281             'elevation': int(stats[month]['elevation']),
    282             'workouts': stats[month]['workouts']
    283         }
    284         json_stats.append(month_stats)
    285     return Response(content_type='application/json',
    286                     charset='utf-8',
    287                     body=json.dumps(json_stats))
Note: See TracChangeset for help on using the changeset viewer.