Localized timezone support (Review Board)
Review Request #2725 — Created Dec. 1, 2011 and submitted
Adds per-user timezone support, relying on the USE_TZ feature from the Django dev branch. Using this method, datetime's are stored in the database in UTC and are timezone-aware. Datetime objects are stored with tzinfo=utc, so that they can be easily converted into any other timezone when retrieved from the database. Middleware was created in the accounts app which activates the user's timezone in each session. A timezone field is added to the user model to store their local time, which they can change in "My account". The user profile and admin forms use TimeZoneField, which is pre-populated with all the available timezone choices. Templates which show dates and/or times are changed to display the user's local time with the {% load tz %}{% localtime on %} tags.
Description | From | Last Updated |
---|---|---|
"timezone" |
chipx86 | |
One per line, ending with commas. |
chipx86 | |
Should be after the siteconfig stuff. Alphabetical order. |
chipx86 | |
Group these together. pytz is a third-party module. |
chipx86 | |
Mind adding a docstring on this? |
chipx86 | |
It's possible that there isn't a Profile yet. For example, if the user just logged in for the very first … |
chipx86 | |
Why did these move? |
chipx86 | |
Get the profile first, in a separate call. Should be self.request.user.get_profile(). |
chipx86 | |
Move semicolon out of the trans block. |
ME medanat | |
"Time Zone:" if we're going to be consistent with other places. |
chipx86 | |
These should be single-space indented. |
mike_conley | |
Just to check, will the result we get back from the API for comparison be in the expected timezone? |
chipx86 | |
Given that this e-mail goes out to admins, I don't think we want to apply the user's timezone to it. … |
chipx86 |
-
-
-
-
-
-
-
It's possible that there isn't a Profile yet. For example, if the user just logged in for the very first time, and is using something like LDAP auth, the User will exist but the Profile won't have been created just yet.
-
-
-
-
-
-
Given that this e-mail goes out to admins, I don't think we want to apply the user's timezone to it. We should, however, make sure to list the timezone in the format. That's using "T"
- Change Summary:
-
Added utc aware datetime helper method, fixed other stuff from review.
- Diff:
-
Revision 2 (+113 -22)
- Change Summary:
-
Added the timezone tag to each individual date within a template. Removed the tag from registerForUpdates. Removed localtime from admin pages and instead added T in the date format.
- Diff:
-
Revision 3 (+112 -33)