From b6273adc571d14fbab4c25742162e9a08ce9df94 Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Tue, 21 Dec 2021 11:19:58 +0100 Subject: [PATCH] Calendar-View: add short_month_day_format for week-views (#2392) --- src/pretix/helpers/formats/en/formats.py | 1 + src/pretix/helpers/formats/en_US/formats.py | 1 + .../event/fragment_subevent_calendar_week.html | 2 +- .../templates/pretixpresale/organizers/calendar_week.html | 2 +- src/pretix/presale/views/event.py | 5 ++++- src/pretix/presale/views/organizer.py | 7 ++++++- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pretix/helpers/formats/en/formats.py b/src/pretix/helpers/formats/en/formats.py index 2d34e8e76..93ee82085 100644 --- a/src/pretix/helpers/formats/en/formats.py +++ b/src/pretix/helpers/formats/en/formats.py @@ -39,3 +39,4 @@ SHORT_DATETIME_FORMAT = 'Y-m-d H:i' TIME_FORMAT = 'H:i' WEEK_FORMAT = '\\W W, o' WEEK_DAY_FORMAT = 'D, M jS' +SHORT_MONTH_DAY_FORMAT = 'd.m.' diff --git a/src/pretix/helpers/formats/en_US/formats.py b/src/pretix/helpers/formats/en_US/formats.py index 45dab2c19..0bb769f80 100644 --- a/src/pretix/helpers/formats/en_US/formats.py +++ b/src/pretix/helpers/formats/en_US/formats.py @@ -26,6 +26,7 @@ SHORT_DATETIME_FORMAT = 'm/d/Y P' TIME_FORMAT = 'P' WEEK_FORMAT = '\\W W, o' WEEK_DAY_FORMAT = 'D, M jS' +SHORT_MONTH_DAY_FORMAT = 'm/d' DATE_INPUT_FORMATS = [ '%m/%d/%Y', diff --git a/src/pretix/presale/templates/pretixpresale/event/fragment_subevent_calendar_week.html b/src/pretix/presale/templates/pretixpresale/event/fragment_subevent_calendar_week.html index 5ea805a6b..b051f9629 100644 --- a/src/pretix/presale/templates/pretixpresale/event/fragment_subevent_calendar_week.html +++ b/src/pretix/presale/templates/pretixpresale/event/fragment_subevent_calendar_week.html @@ -24,7 +24,7 @@ {% endfor %} diff --git a/src/pretix/presale/templates/pretixpresale/organizers/calendar_week.html b/src/pretix/presale/templates/pretixpresale/organizers/calendar_week.html index fa116ebd4..2e17e5fec 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/calendar_week.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/calendar_week.html @@ -30,7 +30,7 @@ {% endfor %} diff --git a/src/pretix/presale/views/event.py b/src/pretix/presale/views/event.py index 6111feeee..cdc2c7fa3 100644 --- a/src/pretix/presale/views/event.py +++ b/src/pretix/presale/views/event.py @@ -77,7 +77,7 @@ from pretix.presale.views.organizer import ( filter_qs_by_attr, weeks_for_template, ) -from ...helpers.formats.en.formats import WEEK_FORMAT +from ...helpers.formats.en.formats import SHORT_MONTH_DAY_FORMAT, WEEK_FORMAT from . import ( CartMixin, EventViewMixin, allow_frame_if_namespaced, get_cart, iframe_entry_view_wrapper, @@ -638,6 +638,9 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView): context['week_format'] = get_format('WEEK_FORMAT') if context['week_format'] == 'WEEK_FORMAT': context['week_format'] = WEEK_FORMAT + context['short_month_day_format'] = get_format('SHORT_MONTH_DAY_FORMAT') + if context['short_month_day_format'] == 'SHORT_MONTH_DAY_FORMAT': + context['short_month_day_format'] = SHORT_MONTH_DAY_FORMAT else: context['subevent_list'] = self.request.event.subevents_sorted( filter_qs_by_attr(self.request.event.subevents_annotated(self.request.sales_channel.identifier).using(settings.DATABASE_REPLICA), self.request) diff --git a/src/pretix/presale/views/organizer.py b/src/pretix/presale/views/organizer.py index 5a4d47f55..c233df0c2 100644 --- a/src/pretix/presale/views/organizer.py +++ b/src/pretix/presale/views/organizer.py @@ -63,7 +63,9 @@ from pretix.base.models import ( from pretix.base.services.quotas import QuotaAvailability from pretix.helpers.compat import date_fromisocalendar from pretix.helpers.daterange import daterange -from pretix.helpers.formats.en.formats import WEEK_FORMAT +from pretix.helpers.formats.en.formats import ( + SHORT_MONTH_DAY_FORMAT, WEEK_FORMAT, +) from pretix.multidomain.urlreverse import eventreverse from pretix.presale.ical import get_ical from pretix.presale.views import OrganizerViewMixin @@ -716,6 +718,9 @@ class WeekCalendarView(OrganizerViewMixin, EventListMixin, TemplateView): ctx['week_format'] = get_format('WEEK_FORMAT') if ctx['week_format'] == 'WEEK_FORMAT': ctx['week_format'] = WEEK_FORMAT + ctx['short_month_day_format'] = get_format('SHORT_MONTH_DAY_FORMAT') + if ctx['short_month_day_format'] == 'SHORT_MONTH_DAY_FORMAT': + ctx['short_month_day_format'] = SHORT_MONTH_DAY_FORMAT ctx['multiple_timezones'] = self._multiple_timezones return ctx