diff --git a/src/pretix/base/models/event.py b/src/pretix/base/models/event.py index b0f3d5052..ab6afbede 100644 --- a/src/pretix/base/models/event.py +++ b/src/pretix/base/models/event.py @@ -156,6 +156,29 @@ class EventMixin: return _date(self.date_from.astimezone(tz), "DATE_FORMAT") return daterange(self.date_from.astimezone(tz), self.date_to.astimezone(tz)) + def get_time_range_display(self, tz=None, force_show_end=False) -> str: + """ + Returns a formatted string containing the start time and sometimes the end time + of the event with respect to the current locale and to the ``show_date_to`` + setting. Dates are not shown. This is usually used in combination with get_date_range_display + """ + tz = tz or self.timezone + + show_date_to = self.date_to and (self.settings.show_date_to or force_show_end) and ( + # Show date to if start and end are on the same day ("08:00-10:00") + self.date_to.astimezone(tz).date() == self.date_from.astimezone(tz).date() or + # Show date to if start and end are on consecutive days and less than 24h ("23:00-03:00") + (self.date_to.astimezone(tz).date() == self.date_from.astimezone(tz).date() + timedelta(days=1) and + self.date_to.astimezone(tz).time() < self.date_from.astimezone(tz).time()) + # Do not show end time if this is a 5-day event because there's no way to make it understandable + ) + if show_date_to: + return '{} – {}'.format( + _date(self.date_from.astimezone(tz), "TIME_FORMAT"), + _date(self.date_to.astimezone(tz), "TIME_FORMAT"), + ) + return _date(self.date_from.astimezone(tz), "TIME_FORMAT") + @property def timezone(self): return pytz.timezone(self.settings.timezone) diff --git a/src/pretix/presale/templates/pretixpresale/event/fragment_cart.html b/src/pretix/presale/templates/pretixpresale/event/fragment_cart.html index 02f29e47e..1edb830a2 100644 --- a/src/pretix/presale/templates/pretixpresale/event/fragment_cart.html +++ b/src/pretix/presale/templates/pretixpresale/event/fragment_cart.html @@ -15,27 +15,44 @@ – {{ line.variation }} {% endif %} {% if line.seat %} -
- - - - {{ line.seat }} +
+ + + + {{ line.seat }} +
{% endif %} {% if line.voucher %} -
{% trans "Voucher code used:" %} {{ line.voucher.code }} +
+ {% trans "Voucher code used:" %} {{ line.voucher.code }} +
{% endif %} {% if line.subevent %} -
{{ line.subevent.name }} · {{ line.subevent.get_date_range_display }} - {% if event.settings.show_times %} - - - {{ line.subevent.date_from|date:"TIME_FORMAT" }} +
+ {{ line.subevent.name }} +
+ + {{ line.subevent.get_date_range_display }} + {% if event.settings.show_times %} + · + {{ line.subevent.get_time_range_display }} + + {% endif %} +
+ {% if line.subevent.location %} + {% if not line.addon_to or line.addon_to.subevent_id != line.subevent_id %} +
+ {{ line.subevent.location|linebreaksbr }} +
+ {% endif %} {% endif %} {% endif %} {% if line.used_membership %} -
{{ line.used_membership }} +
+ {{ line.used_membership }} +
{% endif %} {% if line.issued_gift_cards %} diff --git a/src/pretix/static/pretixpresale/js/ui/cart.js b/src/pretix/static/pretixpresale/js/ui/cart.js index 6ff3a8158..708d15c2f 100644 --- a/src/pretix/static/pretixpresale/js/ui/cart.js +++ b/src/pretix/static/pretixpresale/js/ui/cart.js @@ -79,4 +79,24 @@ $(function () { e.preventDefault(); return true; }); + + $(".cart-icon-details.collapse-lines").each(function () { + var $content = $(this).find(".content"); + var original_html = $content.html(); + var br_exp = //i; + $content.text(original_html.split(br_exp).join(', ')); + if ($content.get(0).scrollWidth > $content.get(0).offsetWidth) { + var $handler = $("