From e5c7c85e753cf15a9441a07182ee59089a3458da Mon Sep 17 00:00:00 2001 From: Mira Weller Date: Fri, 3 May 2024 15:49:47 +0200 Subject: [PATCH] Allow adding products from multiple subevents to the cart at once --- .../event/fragment_product_list.html | 60 +++++++++---------- src/pretix/presale/views/cart.py | 20 +++++-- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html b/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html index b6c5f784d6..e9f6ed5931 100644 --- a/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html +++ b/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html @@ -6,16 +6,16 @@ {% load eventsignal %} {% load rich_text %} {% for tup in items_by_category %} -
+
{% if tup.0 %} -

{{ tup.0.name }}

+

{{ tup.0.name }}

{% if tup.0.description %} -
{{ tup.0.description|localize|rich_text }}
+
{{ tup.0.description|localize|rich_text }}
{% endif %} {% endif %} {% for item in tup.1 %} {% if item.has_variations %} -
+
{% if item.picture %} @@ -29,9 +29,9 @@ {% endif %}
-

{{ item.name }}

+

{{ item.name }}

{% if item.description %} -
+
{{ item.description|localize|rich_text }}
{% endif %} @@ -98,14 +98,14 @@
{% for var in item.available_variations %} -
-
{{ var }}
+
{{ var }}
{% if var.description %} -
+
{{ var.description|localize|rich_text }}
{% endif %} @@ -136,11 +136,11 @@
{{ event.currency }} + {% if var.description %} aria-describedby="{{ tup.2 }}item-{{ item.pk }}-{{ var.pk }}-description"{% endif %}> {% trans "Select" context "checkbox" %} {% else %}
- -
{% endif %} @@ -231,7 +231,7 @@
{% else %} -
@@ -247,9 +247,9 @@ {% endif %}
-

{{ item.name }}

+

{{ item.name }}

{% if item.description %} -
+
{{ item.description|localize|rich_text }}
{% endif %} @@ -290,10 +290,10 @@ + {% if item.description %} aria-describedby="{{ tup.2 }}item-{{ item.id }}-description"{% endif %}> {% trans "Select" context "checkbox" %} {% else %}
- -
{% endif %} diff --git a/src/pretix/presale/views/cart.py b/src/pretix/presale/views/cart.py index 1d73d22fa6..9cdff304a4 100644 --- a/src/pretix/presale/views/cart.py +++ b/src/pretix/presale/views/cart.py @@ -155,17 +155,25 @@ class CartActionMixin: if value.strip() == '' or '_' not in key: return + subevent = None + if key.startswith('subevent_'): + try: + parts = key.split('_', 2) + subevent = int(parts[1]) + key = parts[2] + except ValueError: + pass + elif 'subevent' in self.request.POST: + try: + subevent = int(self.request.POST.get('subevent')) + except ValueError: + pass + if not key.startswith('item_') and not key.startswith('variation_') and not key.startswith('seat_'): return parts = key.split("_") price = self.request.POST.get('price_' + "_".join(parts[1:]), "") - subevent = None - if 'subevent' in self.request.POST: - try: - subevent = int(self.request.POST.get('subevent')) - except ValueError: - pass if key.startswith('seat_'): try: