Localized timezone support (Review Board)
Review Request #2725 — Created Dec. 1, 2011 and submitted
Information | |
---|---|
ddruska | |
Review Board | |
Reviewers | |
reviewboard | |
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" |
|
|
One per line, ending with commas. |
|
|
Should be after the siteconfig stuff. Alphabetical order. |
|
|
Group these together. pytz is a third-party module. |
|
|
Mind adding a docstring on this? |
|
|
It's possible that there isn't a Profile yet. For example, if the user just logged in for the very first … |
|
|
Why did these move? |
|
|
Get the profile first, in a separate call. Should be self.request.user.get_profile(). |
|
|
Move semicolon out of the trans block. |
ME medanat | |
"Time Zone:" if we're going to be consistent with other places. |
|
|
These should be single-space indented. |
|
|
Just to check, will the result we get back from the API for comparison be in the expected timezone? |
|
|
Given that this e-mail goes out to admins, I don't think we want to apply the user's timezone to it. … |
|
-
-
-
-
reviewboard/accounts/forms.py (Diff revision 1) Should be after the siteconfig stuff. Alphabetical order.
-
reviewboard/accounts/middleware.py (Diff revision 1) Group these together. pytz is a third-party module.
-
-
reviewboard/accounts/middleware.py (Diff revision 1) 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.
-
-
reviewboard/reviews/datagrids.py (Diff revision 1) Get the profile first, in a separate call. Should be self.request.user.get_profile().
-
reviewboard/reviews/models.py (Diff revision 1) I feel like we do this so often that we should really have a util function that does it.
-
reviewboard/templates/accounts/prefs.html (Diff revision 1) "Time Zone:" if we're going to be consistent with other places.
-
reviewboard/templates/diffviewer/view_diff.html (Diff revision 1) Just to check, will the result we get back from the API for comparison be in the expected timezone?
-
reviewboard/templates/notifications/new_user_email.html (Diff revision 1) 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"
-
Dave: This looks pretty good! Just found one further nit below. -Mike
-
-
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) |
---|