From 95d19dc656e6816cb4adba7d7ca63f1469c94c9f Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sat, 17 Apr 2021 13:46:29 +0200 Subject: [PATCH] Show collapsed cart on voucher redemption page --- .../event/fragment_cart_box.html | 66 +++++++++++++++++++ .../templates/pretixpresale/event/index.html | 62 +---------------- .../pretixpresale/event/voucher.html | 4 ++ src/pretix/presale/views/cart.py | 7 +- 4 files changed, 76 insertions(+), 63 deletions(-) create mode 100644 src/pretix/presale/templates/pretixpresale/event/fragment_cart_box.html diff --git a/src/pretix/presale/templates/pretixpresale/event/fragment_cart_box.html b/src/pretix/presale/templates/pretixpresale/event/fragment_cart_box.html new file mode 100644 index 0000000000..fa30dfde34 --- /dev/null +++ b/src/pretix/presale/templates/pretixpresale/event/fragment_cart_box.html @@ -0,0 +1,66 @@ +{% load i18n %} +{% load eventurl %} +{% load safelink %} +{% load rich_text %} +{% load money %} +
+ +

+ + + {% trans "Your cart" %} + + + + + +

+
+
+
+ {% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event editable=True %} + + {% if cart.minutes_left > 0 or cart.seconds_left > 0 %} + {% blocktrans trimmed with minutes=cart.minutes_left %} + The items in your cart are reserved for you for {{ minutes }} minutes. + {% endblocktrans %} + {% else %} + {% trans "The items in your cart are no longer reserved for you." %} + {% endif %} + +
+ + +
+
+ {% csrf_token %} + +
+
+
+
+
+
+
diff --git a/src/pretix/presale/templates/pretixpresale/event/index.html b/src/pretix/presale/templates/pretixpresale/event/index.html index 2e5282443f..59d684460e 100644 --- a/src/pretix/presale/templates/pretixpresale/event/index.html +++ b/src/pretix/presale/templates/pretixpresale/event/index.html @@ -26,67 +26,7 @@ {% endautoescape %}
{% if show_cart %} -
- -

- - - {% trans "Your cart" %} - - - - - -

-
-
-
- {% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event editable=True %} - - {% if cart.minutes_left > 0 or cart.seconds_left > 0 %} - {% blocktrans trimmed with minutes=cart.minutes_left %} - The items in your cart are reserved for you for {{ minutes }} minutes. - {% endblocktrans %} - {% else %} - {% trans "The items in your cart are no longer reserved for you." %} - {% endif %} - -
- - -
-
- {% csrf_token %} - -
-
-
-
-
-
-
+ {% include "pretixpresale/event/fragment_cart_box.html" with open=1 %} {% endif %} {% if request.event.has_subevents %} diff --git a/src/pretix/presale/templates/pretixpresale/event/voucher.html b/src/pretix/presale/templates/pretixpresale/event/voucher.html index e178e69e8b..0475c5c78a 100644 --- a/src/pretix/presale/templates/pretixpresale/event/voucher.html +++ b/src/pretix/presale/templates/pretixpresale/event/voucher.html @@ -9,6 +9,10 @@ {% block title %}{% trans "Voucher redemption" %}{% endblock %} {% block content %} + {% if show_cart %} + {% include "pretixpresale/event/fragment_cart_box.html" with open=request.GET.show_cart %} + {% endif %} +

{% trans "Voucher redemption" %}

{% if subevent %} diff --git a/src/pretix/presale/views/cart.py b/src/pretix/presale/views/cart.py index 3595cc1be1..11bbbcb6cc 100644 --- a/src/pretix/presale/views/cart.py +++ b/src/pretix/presale/views/cart.py @@ -66,7 +66,7 @@ from pretix.base.views.tasks import AsyncAction from pretix.multidomain.urlreverse import eventreverse from pretix.presale.views import ( EventViewMixin, allow_cors_if_namespaced, allow_frame_if_namespaced, - iframe_entry_view_wrapper, + iframe_entry_view_wrapper, CartMixin, ) from pretix.presale.views.event import ( get_grouped_items, item_group_by_category, @@ -513,7 +513,7 @@ class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View): @method_decorator(allow_frame_if_namespaced, 'dispatch') @method_decorator(iframe_entry_view_wrapper, 'dispatch') -class RedeemView(NoSearchIndexViewMixin, EventViewMixin, TemplateView): +class RedeemView(NoSearchIndexViewMixin, EventViewMixin, CartMixin, TemplateView): template_name = "pretixpresale/event/voucher.html" def get_context_data(self, **kwargs): @@ -541,6 +541,9 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, TemplateView): for item in items if item.has_variations ) + context['cart'] = self.get_cart() + context['show_cart'] = context['cart']['positions'] + # Regroup those by category context['items_by_category'] = item_group_by_category(items)