Changeset dbfab70 in OpenWorkouts-current for ow/views/user.py


Ignore:
Timestamp:
Jan 31, 2019, 12:33:38 PM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
1183d5a, 9ab0fe3
Parents:
8fedd17
Message:

(#7) Show workouts in the profile page related to the highlighted/current month

selected in the yearly chart.

Also, allow users to click on the monthly bars on the chart, to choose that month.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/views/user.py

    r8fedd17 rdbfab70  
    166166    """
    167167    now = datetime.now(timezone.utc)
    168     return {
    169         'current_month': now.strftime('%Y-%m')
     168    year = int(request.GET.get('year', now.year))
     169    month = int(request.GET.get('month', now.month))
     170    return {
     171        'workouts': context.workouts(year, month),
     172        'current_month': '{year}-{month}'.format(
     173            year=str(year), month=str(month).zfill(2))
    170174    }
    171175
     
    280284            'distance': int(round(stats[month]['distance'])),
    281285            'elevation': int(stats[month]['elevation']),
    282             'workouts': stats[month]['workouts']
     286            'workouts': stats[month]['workouts'],
     287            'url': request.resource_url(
     288                context, 'profile',
     289                query={'year': str(month[0]), 'month': str(month[1])},
     290                anchor='workouts')
    283291        }
    284292        json_stats.append(month_stats)
Note: See TracChangeset for help on using the changeset viewer.