diff --git a/src/core/models/conference.py b/src/core/models/conference.py index 773a09b1e4a4e9d0fb5387147fdf9b95569c7885..922246c2f1b6a2113fab09dc3c9041e8a4b91c19 100644 --- a/src/core/models/conference.py +++ b/src/core/models/conference.py @@ -152,6 +152,7 @@ class Conference(models.Model): help_text=_('Conference__end__help'), verbose_name=_('Conference__end')) + # TODO Feld auf TimeZoneField umbauen timezone = models.CharField( choices=[(tz, tz) for tz in pytz.common_timezones], max_length=30, diff --git a/src/plainui/jinja2/plainui/fahrplan.html b/src/plainui/jinja2/plainui/fahrplan.html index 297413cd23256e073f20e1b8dc7c4d87c4a74353..a97b492902ed3923fc7d5328c945fc1d080bad25 100644 --- a/src/plainui/jinja2/plainui/fahrplan.html +++ b/src/plainui/jinja2/plainui/fahrplan.html @@ -8,6 +8,10 @@ {{ titleMacro.title(_("schedule"), share_url = url('plainui:fahrplan', conf_slug=conf.slug), report_url = url('plainui:fahrplan', conf_slug=conf.slug)) }} + {% if timezone_warning %} + <div class="text-warning">{{ _("Warning, your timezone is configured to %(user_timezone)s and does not match the conference timezone %(conf_timezone)s", user_timezone=current_timezone, conf_timezone=conference_timezone) }}</div> + {% endif %} + {# TODO: Download options <h2>{{ _("download") }}</h2> diff --git a/src/plainui/jinja2/plainui/my_fahrplan.html b/src/plainui/jinja2/plainui/my_fahrplan.html index 5b7f3de3a041b89b02897b0718f6b424e6a10d38..60d5bd1080aff15791719198eea2561d744114e2 100644 --- a/src/plainui/jinja2/plainui/my_fahrplan.html +++ b/src/plainui/jinja2/plainui/my_fahrplan.html @@ -7,6 +7,9 @@ {{ titleMacro.title(_("personal schedule"), share_url = url('plainui:my_fahrplan', conf_slug=conf.slug), report_url = url('plainui:my_fahrplan', conf_slug=conf.slug)) }} + {% if timezone_warning %} + <div class="text-warning">{{ _("Warning, your timezone is configured to %(user_timezone)s and does not match the conference timezone %(conf_timezone)s", user_timezone=current_timezone, conf_timezone=conference_timezone) }}</div> + {% endif %} {# TODO: Download options <h2>{{ _("download") }}</h2> diff --git a/src/plainui/jinja2/plainui/public_fahrplan.html b/src/plainui/jinja2/plainui/public_fahrplan.html index f506ab812e7d1596ea2cb09a966757b37c60a65a..913a0f146171df3c198c90f707317481c4e89e31 100644 --- a/src/plainui/jinja2/plainui/public_fahrplan.html +++ b/src/plainui/jinja2/plainui/public_fahrplan.html @@ -17,6 +17,9 @@ </head> <body class="rc3-fahrplan__pub-body p-4"> <h1 class="h2">{{ _("%(conf)s Fahrplan", conf=conf.name) }}</h1> + {% if timezone_warning %} + <div class="text-warning">{{ _("Warning, your timezone is configured to %(user_timezone)s and does not match the conference timezone %(conf_timezone)s", user_timezone=current_timezone, conf_timezone=conference_timezone) }}</div> + {% endif %} {% if mode == 'list' %} {{ list_events.list(events, [], []) }} diff --git a/src/plainui/locale/de/LC_MESSAGES/django.po b/src/plainui/locale/de/LC_MESSAGES/django.po index 4c5304796006b1e97493fd90acf146dcee642646..9d5c6719a6761853c8b39c87a281ca0211239d10 100644 --- a/src/plainui/locale/de/LC_MESSAGES/django.po +++ b/src/plainui/locale/de/LC_MESSAGES/django.po @@ -778,6 +778,10 @@ msgstr "Anhänge" msgid "schedule" msgstr "Zeitplan" +#, python-format +msgid "Warning, your timezone is configured to %(user_timezone)s and does not match the conference timezone %(conf_timezone)s" +msgstr "Achtung, deine Zeitzone ist auf %(user_timezone)s eingestellt und entspricht nicht der Konferenzzeitzone %(conf_timezone)s" + #, python-format msgid "Day %(n)s" msgstr "" diff --git a/src/plainui/locale/en/LC_MESSAGES/django.po b/src/plainui/locale/en/LC_MESSAGES/django.po index 0617abe4ee03a567f570a3c78474388b2fc1751f..6536c1adb387dd43064e5be1f89c96def63c8447 100644 --- a/src/plainui/locale/en/LC_MESSAGES/django.po +++ b/src/plainui/locale/en/LC_MESSAGES/django.po @@ -778,6 +778,10 @@ msgstr "" msgid "schedule" msgstr "" +#, python-format +msgid "Warning, your timezone is configured to %(user_timezone)s and does not match the conference timezone %(conf_timezone)s" +msgstr "" + #, python-format msgid "Day %(n)s" msgstr "" diff --git a/src/plainui/views.py b/src/plainui/views.py index 97019fb26c3f990e7ca50a7434d0fc3329dcb33a..5cf780429b44e6e6fffb3c317ad92e3bb574184a 100644 --- a/src/plainui/views.py +++ b/src/plainui/views.py @@ -1,6 +1,7 @@ from datetime import time, timedelta from functools import lru_cache from typing import List +import pytz from django.conf import settings from django.contrib import messages @@ -1224,6 +1225,17 @@ class FahrplanView(ConferenceRequiredMixin, TemplateView): context = super().get_context_data(conf_slug=conf_slug, **kwargs) context['conf'] = self.conf + try: + timezone_warning = timezone.get_current_timezone() != pytz.timezone(self.conf.timezone) + context['timezone_warning'] = timezone_warning + if timezone_warning: + current_timezone = timezone.get_current_timezone() + if current_timezone is not None: + context['current_timezone'] = current_timezone.zone + context['conference_timezone'] = self.conf.timezone + except pytz.UnknownTimeZoneError: + context['timezone_warning'] = False + context['my_favorite_events'] = _session_get_favorite_events(self.request.session, self.request.user) context['my_scheduled_events'] = _session_get_scheduled_events(self.request.session, self.request.user) @@ -1344,6 +1356,20 @@ class PublicFahrplanView(ConferenceRequiredMixin, TemplateView): def get_context_data(self, **kwargs): context = super().get_context_data(conf=self.conf, **kwargs) context['mode'] = 'calendar' + + # TODO: Timezone warning macht im public fahrplan keinen Sinn, wir stirppen momentan die Sessions im Loadbalancer. + # Da sollten wir immer in der offiziellen Zeit anzeigen. Eventuell mit dauerhaftem Timezone-Hinweis? + try: + timezone_warning = self.conf.timezone and timezone.get_current_timezone() != pytz.timezone(self.conf.timezone) + context['timezone_warning'] = timezone_warning + if timezone_warning: + current_timezone = timezone.get_current_timezone() + if current_timezone is not None: + context['current_timezone'] = current_timezone.zone + context['conference_timezone'] = self.conf.timezone + except pytz.UnknownTimeZoneError: + context['timezone_warning'] = False + events = _event_filter(self.request.user, self.conf, public_fahrplan=True) # events = _event_filter(self.request.user, self.conf) context['events'] = _organize_events_for_calendar(self.conf, events)