Changeset 31adfa5 in OpenWorkouts-current for ow/schemas


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/schemas/user.py

    rd507f75 r31adfa5  
    11from pyramid.i18n import TranslationStringFactory
    22from formencode import Schema, validators
     3from pytz import common_timezones
    34
    45from ow.schemas.blob import FieldStorageBlob
     
    7475    picture = FieldStorageBlob(if_emtpy=None, if_missing=None,
    7576                               whitelist=['jpg', 'jpeg', 'png', 'gif'])
     77    timezone = validators.OneOf(common_timezones, if_missing='UTC')
    7678
    7779
Note: See TracChangeset for help on using the changeset viewer.