Use correct timezone for events in event list view

This commit is contained in:
Raphael Michel
2020-01-28 13:32:43 +01:00
parent 889dd651ef
commit 29ff5b9416
2 changed files with 12 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
{% extends "pretixpresale/organizers/base.html" %}
{% load i18n %}
{% load rich_text %}
{% load tz %}
{% load eventurl %}
{% load urlreplace %}
{% load thumb %}
@@ -68,12 +69,14 @@
<td>
{{ e.daterange|default:e.get_date_range_display }}
{% if e.settings.show_times %}
<br><small class="text-muted">
{{ e.date_from|date:"TIME_FORMAT" }}
{% if e.settings.show_date_to and e.date_to and e.date_to.date == e.date_from.date %}
{{ e.date_to|date:"TIME_FORMAT" }}
{% endif %}
</small>
{% timezone e.tzname %}
<br><small class="text-muted">
{{ e.date_from|date:"TIME_FORMAT" }}
{% if e.settings.show_date_to and e.date_to and e.date_to.date == e.date_from.date %}
{{ e.date_to|date:"TIME_FORMAT" }}
{% endif %}
</small>
{% endtimezone %}
{% endif %}
</td>
<td>

View File

@@ -214,11 +214,11 @@ class OrganizerIndex(OrganizerViewMixin, EventListMixin, ListView):
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
for event in ctx['events']:
tz = pytz.timezone(event.cache.get_or_set('timezone', lambda: event.settings.timezone))
event.tzname = pytz.timezone(event.cache.get_or_set('timezone', lambda: event.settings.timezone))
if event.has_subevents:
event.daterange = daterange(
event.min_from.astimezone(tz),
(event.max_fromto or event.max_to or event.max_from).astimezone(tz)
event.min_from.astimezone(event.tzname),
(event.max_fromto or event.max_to or event.max_from).astimezone(event.tzname)
)
return ctx