mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
Time machine mode [Z#23129725] (#3961)
Allows organizers to test their shop as if it were a different date and time. Implemented using a time_machine_now() function which is used instead of regular now(), which can overlay the real date time with a value from a ContextVar, assigned from a session value in EventMiddleware. For more information, see doc/development/implementation/timemachine.rst --------- Co-authored-by: Richard Schreiber <schreiber@rami.io> Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
@@ -37,6 +37,7 @@ 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
|
||||
|
||||
from .utils import _detect_event
|
||||
@@ -68,7 +69,8 @@ class EventMiddleware:
|
||||
if redirect:
|
||||
return redirect
|
||||
|
||||
with scope(organizer=getattr(request, 'organizer', None)):
|
||||
with scope(organizer=getattr(request, 'organizer', None)), \
|
||||
time_machine_now_assigned_from_request(request):
|
||||
response = self.get_response(request)
|
||||
|
||||
if hasattr(request, '_namespace') and request._namespace == 'presale' and hasattr(request, 'event'):
|
||||
|
||||
Reference in New Issue
Block a user