Пример #1
0
def get_club(club):
    """
    Get club information from database or strava.
    """
    try:
        return Club.get(strava_id=club)
    except Club.DoesNotExist:
        return fetch_club(club)
Пример #2
0
def fetch_club(club):
    """
    Fetch and store club information and members from strava.
    """
    data = load_json('http://app.strava.com/api/v1/clubs/%s/members' % club)
    instance = Club.get_or_create(strava_id=club).values_from_dict(data['club'], {'id': 'strava_id'})
    instance.save()

    fetch_athletes(club, data=data)

    return instance
Пример #3
0
def render_template(*args, **kwargs):
    kwargs.update({
        'clubs': Club.all_augmented(),
        'club': kwargs.get('club') or (session.get('club_id') and get_club(session.get('club_id')))
    })
    return flask_render_template(*args, **kwargs)
Пример #4
0
def update():
    for club in Club.all():
        print "Updating: ", club.strava_id
        update_club(club)