[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
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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/>
|
||||
|
||||
Reference in New Issue
Block a user