summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2018-01-22 12:04:27 +0100
committerNicolas Lempereur <nle@odoo.com>2018-01-22 12:38:52 +0100
commit7a63d471edec45a106fef5f783aeb7eaf43447f6 (patch)
treee54183e6ba7a25c6bf40f97182b6c904ce6fbb35
parentaac9cd4ca8080335ab794098c04d007ca3fb2461 (diff)
[FIX] website_event_track: use event timezone
Depending on the location, on the website different timezone were used to display tracks: - in `Agenda` day date (as of saas-14): the current user timezone - in `Agenda` track times: the event timezone - in `Talks` subtitle: the event timezone - in `Talks` tracks: the current user timezone - in a track page: the first user (admin) timezone With this change in all those instance the event timezone is used. There is still a usability hindrance in the backend: the timezone used when encoding track or event datetime is the browser timezone. So if the browser is GMT+2 and the event is GMT+6, encoding a 4h00 time would save it as 2h00 (in UTC) and display it on the website as 8h00. This would make sense to encode these datetime in user timezone but currently there is no framework option to do it. opw-805358 closes #22427
-rw-r--r--addons/website_event_track/controllers/main.py4
-rw-r--r--addons/website_event_track/views/website_event_track_templates.xml4
2 files changed, 6 insertions, 2 deletions
diff --git a/addons/website_event_track/controllers/main.py b/addons/website_event_track/controllers/main.py
index 296ba70ecc6..cf69304a87c 100644
--- a/addons/website_event_track/controllers/main.py
+++ b/addons/website_event_track/controllers/main.py
@@ -14,7 +14,7 @@ class WebsiteEventTrackController(http.Controller):
@http.route(['''/event/<model("event.event"):event>/track/<model("event.track", "[('event_id','=',event[0])]"):track>'''], type='http', auth="public", website=True)
def event_track_view(self, event, track, **post):
- track = track.sudo()
+ track = track.sudo().with_context(tz=event.date_tz or 'UTC')
values = {'track': track, 'event': track.event_id, 'main_object': track}
return request.render("website_event_track.track_view", values)
@@ -55,6 +55,7 @@ class WebsiteEventTrackController(http.Controller):
@http.route(['''/event/<model("event.event", "[('show_tracks','=',1)]"):event>/agenda'''], type='http', auth="public", website=True)
def event_agenda(self, event, tag=None, **post):
+ event = event.with_context(tz=event.date_tz or 'UTC')
local_tz = pytz.timezone(event.date_tz or 'UTC')
days_tracks = collections.defaultdict(lambda: [])
for track in event.track_ids.sorted(lambda track: (track.date, bool(track.location_id))):
@@ -87,6 +88,7 @@ class WebsiteEventTrackController(http.Controller):
'''/event/<model("event.event", "[('show_tracks','=',1)]"):event>/track/tag/<model("event.track.tag"):tag>'''
], type='http', auth="public", website=True)
def event_tracks(self, event, tag=None, **post):
+ event = event.with_context(tz=event.date_tz or 'UTC')
searches = {}
if tag:
searches.update(tag=tag.id)
diff --git a/addons/website_event_track/views/website_event_track_templates.xml b/addons/website_event_track/views/website_event_track_templates.xml
index adb6ae74214..867b4fd4f70 100644
--- a/addons/website_event_track/views/website_event_track_templates.xml
+++ b/addons/website_event_track/views/website_event_track_templates.xml
@@ -250,7 +250,9 @@
</div>
<div class="panel-body">
<b>Date</b><br/>
- <span t-field="track.date" t-options='{"hide_seconds":"True"}'/><br/>
+ <span t-field="track.date" t-options='{"hide_seconds":"True"}'/>
+ <t t-if="event.date_tz">(<span t-field="event.date_tz"/>)</t>
+ <br/>
<b>Duration</b><br/>
<span t-field="track.duration" t-options='{"widget": "duration", "unit": "hour", "round": "minute"}'/><br/>
<b>Location</b><br/>