New implementation of sales channels (#4111)

Co-authored-by: Martin Gross <gross@rami.io>
This commit is contained in:
Raphael Michel
2024-06-30 19:24:30 +02:00
committed by GitHub
parent 95511b0330
commit 4fb5c6bef0
174 changed files with 2902 additions and 616 deletions

View File

@@ -36,7 +36,6 @@ from django.template.response import TemplateResponse
from django.urls import resolve
from django_scopes import scope
from pretix.base.channels import WebshopSalesChannel
from pretix.base.timemachine import time_machine_now_assigned_from_request
from pretix.presale.signals import process_response
@@ -57,10 +56,6 @@ class EventMiddleware:
url = resolve(request.path_info)
request._namespace = url.namespace
if not hasattr(request, 'sales_channel'):
# The environ lookup is only relevant during unit testing
request.sales_channel = request.environ.get('PRETIX_SALES_CHANNEL', WebshopSalesChannel())
if url.namespace != 'presale':
return self.get_response(request)
@@ -71,6 +66,12 @@ class EventMiddleware:
with scope(organizer=getattr(request, 'organizer', None)), \
time_machine_now_assigned_from_request(request):
if not hasattr(request, 'sales_channel') and hasattr(request, 'organizer'):
# The environ lookup is only relevant during unit testing
request.sales_channel = request.organizer.sales_channels.get(
identifier=request.environ.get('PRETIX_SALES_CHANNEL', 'web')
)
response = self.get_response(request)
if hasattr(request, '_namespace') and request._namespace == 'presale' and hasattr(request, 'event'):