From 217ed905d48469514d0fbce6ee7b284ebcef3c30 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 4 Oct 2017 10:12:46 +0200 Subject: [PATCH] Contract columns in event list table --- src/pretix/base/models/event.py | 25 +++++++++++++++ .../templates/pretixcontrol/events/index.html | 31 ++++++++----------- .../static/pretixcontrol/scss/main.scss | 4 +++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/pretix/base/models/event.py b/src/pretix/base/models/event.py index 5ff910b78..2005393ba 100644 --- a/src/pretix/base/models/event.py +++ b/src/pretix/base/models/event.py @@ -38,6 +38,31 @@ class EventMixin: raise ValidationError({'date_to': _('The end of the event has to be later than its start.')}) super().clean() + def get_short_date_from_display(self, tz=None, show_times=True) -> str: + """ + Returns a shorter formatted string containing the start date of the event with respect + to the current locale and to the ``show_times`` setting. + """ + tz = tz or pytz.timezone(self.settings.timezone) + return _date( + self.date_from.astimezone(tz), + "SHORT_DATETIME_FORMAT" if self.settings.show_times and show_times else "DATE_FORMAT" + ) + + def get_short_date_to_display(self, tz=None) -> str: + """ + Returns a shorter formatted string containing the start date of the event with respect + to the current locale and to the ``show_times`` setting. Returns an empty string + if ``show_date_to`` is ``False``. + """ + tz = tz or pytz.timezone(self.settings.timezone) + if not self.settings.show_date_to or not self.date_to: + return "" + return _date( + self.date_to.astimezone(tz), + "SHORT_DATETIME_FORMAT" if self.settings.show_times else "DATE_FORMAT" + ) + def get_date_from_display(self, tz=None, show_times=True) -> str: """ Returns a formatted string containing the start date of the event with respect diff --git a/src/pretix/control/templates/pretixcontrol/events/index.html b/src/pretix/control/templates/pretixcontrol/events/index.html index 617961a4d..afb2ad302 100644 --- a/src/pretix/control/templates/pretixcontrol/events/index.html +++ b/src/pretix/control/templates/pretixcontrol/events/index.html @@ -51,11 +51,6 @@ {% trans "Event name" %} - - {% trans "Short form" %} - - - {% if not hide_orga %} {% trans "Organizer" %} @@ -67,8 +62,7 @@ {% trans "Start date" %} - - + / {% trans "End date" %} @@ -83,26 +77,27 @@ {% for e in events %} - + {{ e.name }} {% if e.has_subevents %} {% trans "Series" %} {% endif %} +
{{ e.slug }} - {{ e.slug }} {% if not hide_orga %}{{ e.organizer }}{% endif %} - + {% if e.has_subevents %} - {{ e.min_from|default_if_none:"" }} + {{ e.min_from|default_if_none:""|date:"SHORT_DATETIME_FORMAT" }} {% else %} - {{ e.get_date_from_display }} + {{ e.get_short_date_from_display }} {% endif %} - - - {% if e.has_subevents %} - {{ e.max_fromto|default_if_none:e.max_from|default_if_none:e.max_to|default_if_none:"" }} - {% else %} - {{ e.get_date_from_display }} + {% if e.settings.show_date_to and e.date_to %} +
– + {% if e.has_subevents %} + {{ e.max_fromto|default_if_none:e.max_from|default_if_none:e.max_to|default_if_none:""|date:"SHORT_DATETIME_FORMAT" }} + {% else %} + {{ e.get_short_date_to_display }} + {% endif %} {% endif %} diff --git a/src/pretix/static/pretixcontrol/scss/main.scss b/src/pretix/static/pretixcontrol/scss/main.scss index d7a7c8b50..f4e7f3dee 100644 --- a/src/pretix/static/pretixcontrol/scss/main.scss +++ b/src/pretix/static/pretixcontrol/scss/main.scss @@ -399,3 +399,7 @@ body.loading #wrapper { .fa.disabled { color: $text-muted; } + +.event-name-col { + width: 30%; +}