forked from CGM_Public/pretix_original
CartAdd with subevents: Useful redirect in error case
This commit is contained in:
@@ -252,7 +252,7 @@
|
|||||||
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
||||||
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
||||||
class="{% if event.seating_plan_id %}has-seating{% endif %}"
|
class="{% if event.seating_plan_id %}has-seating{% endif %}"
|
||||||
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}">
|
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}&next_error={{ request.path|urlencode }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
||||||
{% if ev.seating_plan_id and event.settings.seating_choice %}
|
{% if ev.seating_plan_id and event.settings.seating_choice %}
|
||||||
|
|||||||
@@ -71,6 +71,19 @@ class CartActionMixin:
|
|||||||
return self.get_next_url()
|
return self.get_next_url()
|
||||||
|
|
||||||
def get_error_url(self):
|
def get_error_url(self):
|
||||||
|
if "next_error" in self.request.GET and is_safe_url(self.request.GET.get("next_error"), allowed_hosts=None):
|
||||||
|
u = self.request.GET.get('next_error')
|
||||||
|
if '?' in u:
|
||||||
|
u += '&require_cookie=true'
|
||||||
|
else:
|
||||||
|
u += '?require_cookie=true'
|
||||||
|
disclose_cart_id = (
|
||||||
|
'iframe' in self.request.GET or settings.SESSION_COOKIE_NAME not in self.request.COOKIES
|
||||||
|
) and self.kwargs.get('cart_namespace')
|
||||||
|
if disclose_cart_id:
|
||||||
|
cart_id = get_or_create_cart_id(self.request)
|
||||||
|
u += '&cart_id={}'.format(cart_id)
|
||||||
|
return u
|
||||||
return self.get_next_url()
|
return self.get_next_url()
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
@@ -413,6 +426,8 @@ class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View):
|
|||||||
u = super().get_check_url(task_id, ajax)
|
u = super().get_check_url(task_id, ajax)
|
||||||
if "next" in self.request.GET:
|
if "next" in self.request.GET:
|
||||||
u += "&next=" + quote(self.request.GET.get('next'))
|
u += "&next=" + quote(self.request.GET.get('next'))
|
||||||
|
if "next_error" in self.request.GET:
|
||||||
|
u += "&next_error=" + quote(self.request.GET.get('next_error'))
|
||||||
if ajax:
|
if ajax:
|
||||||
cart_id = get_or_create_cart_id(self.request)
|
cart_id = get_or_create_cart_id(self.request)
|
||||||
u += '&take_cart_id=' + cart_id
|
u += '&take_cart_id=' + cart_id
|
||||||
|
|||||||
Reference in New Issue
Block a user