mirror of
https://github.com/pretix/pretix.git
synced 2026-08-11 10:57:00 +00:00
Pass widget_data to new tab even if 3rd-party cookies are disabled (Z#23176995)
This commit is contained in:
@@ -182,7 +182,7 @@
|
||||
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 %}"
|
||||
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 }}&next_error={{ request.path|urlencode }}">
|
||||
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}&next_error={{ request.path|urlencode }}{{ take_cart_id_param }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
||||
{% if ev.seating_plan_id and event.settings.seating_choice %}
|
||||
|
||||
@@ -307,7 +307,7 @@ def create_empty_cart_id(request, replace_current=True):
|
||||
return new_id
|
||||
|
||||
|
||||
def get_or_create_cart_id(request, create=True):
|
||||
def get_or_create_cart_id(request, create=True, cache_widget_data=False):
|
||||
"""
|
||||
This method returns the cart ID in use for this request or creates a new cart ID if required.
|
||||
|
||||
@@ -404,6 +404,9 @@ def get_or_create_cart_id(request, create=True):
|
||||
cart_data['widget_data'] = json.loads(request.GET.get('widget_data'))
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
if cache_widget_data:
|
||||
widget_data_cache.set('widget_data_{}'.format(new_id), cart_data['widget_data'], 600)
|
||||
|
||||
if 'carts' not in request.session:
|
||||
request.session['carts'] = {}
|
||||
|
||||
@@ -505,7 +505,7 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
||||
get_or_create_cart_id(request)
|
||||
return redirect_to_url(eventreverse(request.event, 'presale:event.index', kwargs=kwargs) + '?' + urlencode(utm_params))
|
||||
elif request.GET.get('iframe', '') == '1' and 'take_cart_id' in request.GET:
|
||||
# Widget just opened, a cart already exists. Let's to a stupid redirect to check if cookies are disabled
|
||||
# Widget just opened, a cart already exists. Let's do a stupid redirect to check if cookies are disabled
|
||||
get_or_create_cart_id(request)
|
||||
return redirect_to_url(eventreverse(request.event, 'presale:event.index', kwargs=kwargs) + '?' + urlencode({
|
||||
'require_cookie': 'true',
|
||||
@@ -515,7 +515,7 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
||||
}))
|
||||
elif request.GET.get('iframe', '') == '1' and len(self.request.GET.get('widget_data', '{}')) > 3:
|
||||
# We've been passed data from a widget, we need to create a cart session to store it.
|
||||
get_or_create_cart_id(request)
|
||||
get_or_create_cart_id(request, cache_widget_data=True)
|
||||
elif 'require_cookie' in request.GET and settings.SESSION_COOKIE_NAME not in request.COOKIES and \
|
||||
'__Host-' + settings.SESSION_COOKIE_NAME not in self.request.COOKIES:
|
||||
# Cookies are in fact not supported
|
||||
@@ -644,6 +644,10 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
||||
else:
|
||||
context['cart_redirect'] = self.request.path
|
||||
|
||||
if 'cart_namespace' in self.kwargs and self.request.GET.get('iframe') == '1' and 'take_cart_id' in self.request.GET:
|
||||
from pretix.presale.views.cart import get_or_create_cart_id
|
||||
context['take_cart_id_param'] = '&take_cart_id=' + get_or_create_cart_id(self.request)
|
||||
|
||||
return context
|
||||
|
||||
def _subevent_list_cachekey(self):
|
||||
|
||||
Reference in New Issue
Block a user