Added a signal for processing event requests

This commit is contained in:
Raphael Michel
2016-07-28 21:02:29 +02:00
parent cf898b3c33
commit 7514b9bab2
3 changed files with 27 additions and 0 deletions

View File

@@ -45,3 +45,19 @@ This signal is sent out to display additional information on the order detail pa
As with all plugin signals, the ``sender`` keyword argument will contain the event.
"""
process_request = EventPluginSignal(
providing_args=["request"]
)
"""
This signal is sent out whenever a request is made to a event presale page. Most of the
time, this will be called from the middleware layer (except on plugin-provided pages
this will be caled by the @event_view decorator). Similarly to Django's process_request
middleware method, if you return a Response, that response will be used and the request
won't be processed any further down the stack.
WARNING: Be very careful about using this signal as listening to it makes it really
easy to cause serious performance problems.
As with all plugin signals, the ``sender`` keyword argument will contain the event.
"""

View File

@@ -9,6 +9,7 @@ from django.utils.translation import ugettext_lazy as _
from pretix.base.middleware import LocaleMiddleware
from pretix.base.models import Event, EventPermission, Organizer
from pretix.multidomain.urlreverse import get_domain
from pretix.presale.signals import process_request
def _detect_event(request):
@@ -63,6 +64,10 @@ def _detect_event(request):
event=request.event, user=request.user).exists():
raise PermissionDenied(_('The selected ticket shop is currently not available.'))
for receiver, response in process_request.send(request.event, request=request):
if response:
return response
except Event.DoesNotExist:
raise Http404(_('The selected event was not found.'))
except Organizer.DoesNotExist: