Changeset 31adfa5 in OpenWorkouts-current for ow/views


Ignore:
Timestamp:
Dec 21, 2018, 11:00:25 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
fe6089a
Parents:
d507f75
Message:

(#14) Timezones support:

  • Added pytz as a new dependency, please install it in your existing envs:

pip install pytz

  • Added a timezone attribute to users, to store in which timezone they are, defaults to 'UTC'. Ensure any users you could have in your database have such attribute. You can add it in pshell:

for user in root.users:

user.timezone = 'UTC'

request.tm.commit()

  • Modified schemas/templates/views to let users choose their timezone based on a list of "common" timezones provided by pytz
  • Added two methods to the Workout model so we can get the start and end dates formatted in the appropiate timezone (all datetime objects are stored in UTC)
  • Modified the templates where we show workout dates and times so the new timezone-formatting methods are used.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/views/user.py

    rd507f75 r31adfa5  
    55from pyramid.i18n import TranslationStringFactory
    66from pyramid_simpleform import Form, State
     7from pytz import common_timezones
    78
    89from ..models.user import User
     
    167168        # Saved, send the user to the public view of her profile
    168169        return HTTPFound(location=request.resource_url(context, 'profile'))
     170
    169171    # prevent crashes on the form
    170172    if 'picture' in form.data:
    171173        del form.data['picture']
    172     return {'form': OWFormRenderer(form)}
     174
     175    return {'form': OWFormRenderer(form),
     176            'timezones': common_timezones}
    173177
    174178
Note: See TracChangeset for help on using the changeset viewer.