forked from CGM_Public/pretix_original
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:
@@ -46,11 +46,11 @@ from pretix.base.settings import GlobalSettingsObject
|
||||
from pretix.control.navigation import (
|
||||
get_event_navigation, get_global_navigation, get_organizer_navigation,
|
||||
)
|
||||
|
||||
from ..helpers.i18n import (
|
||||
from pretix.helpers.i18n import (
|
||||
get_javascript_format, get_javascript_output_format, get_moment_locale,
|
||||
)
|
||||
from ..multidomain.urlreverse import get_event_domain
|
||||
from pretix.multidomain.urlreverse import get_event_domain
|
||||
|
||||
from .signals import html_head, nav_topbar
|
||||
|
||||
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
|
||||
@@ -106,7 +106,7 @@ def _default_context(request):
|
||||
else:
|
||||
ctx['complain_testmode_orders'] = False
|
||||
|
||||
if not request.event.live and ctx['has_domain']:
|
||||
if (request.event.testmode or not request.event.live) and ctx['has_domain']:
|
||||
child_sess = request.session.get('child_session_{}'.format(request.event.pk))
|
||||
s = SessionStore()
|
||||
if not child_sess or not s.exists(child_sess):
|
||||
@@ -114,10 +114,8 @@ def _default_context(request):
|
||||
s.create()
|
||||
ctx['new_session'] = s.session_key
|
||||
request.session['child_session_{}'.format(request.event.pk)] = s.session_key
|
||||
request.session['event_access'] = True
|
||||
else:
|
||||
ctx['new_session'] = child_sess
|
||||
request.session['event_access'] = True
|
||||
|
||||
if request.GET.get('subevent', ''):
|
||||
# Do not use .get() for lazy evaluation
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="test-right">
|
||||
<div class="text-right">
|
||||
<button type="submit" class="btn btn-primary btn-lg btn-save" disabled>
|
||||
{% trans "Go live" %}
|
||||
</button>
|
||||
@@ -82,10 +82,10 @@
|
||||
<p>
|
||||
{% trans "Your shop is currently in test mode. All orders are not persistent and can be deleted at any point." %}
|
||||
</p>
|
||||
<div class="form-inline">
|
||||
<label class="checkbox">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="delete" value="yes" />
|
||||
{% trans "Permanently delete all orders created in test mode" %}
|
||||
<b>{% trans "Permanently delete all orders created in test mode" %}</b>
|
||||
</label>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{% load eventurl %}
|
||||
{% load static %}
|
||||
<form action="{% eventurl request.event "presale:event.auth" %}{% if request.GET.next %}?next={{ request.GET.next }}{% endif %}" method="post">
|
||||
<input type="hidden" value="{{ new_session }}" name="session">
|
||||
<button type="submit">
|
||||
Continue
|
||||
</button>
|
||||
</form>
|
||||
<script src="{% static "pretixcontrol/js/send_form.js" %}"></script>
|
||||
@@ -247,6 +247,7 @@ urlpatterns = [
|
||||
re_path(r'^widgets.json$', dashboards.event_index_widgets_lazy, name='event.index.widgets'),
|
||||
re_path(r'^logs/embed$', dashboards.event_index_log_lazy, name='event.index.logs'),
|
||||
re_path(r'^live/$', event.EventLive.as_view(), name='event.live'),
|
||||
re_path(r'^transfer_session/$', event.EventTransferSession.as_view(), name='event.transfer_session'),
|
||||
re_path(r'^logs/$', event.EventLog.as_view(), name='event.log'),
|
||||
re_path(r'^delete/$', event.EventDelete.as_view(), name='event.delete'),
|
||||
re_path(r'^comment/$', event.EventComment.as_view(),
|
||||
|
||||
@@ -1017,6 +1017,11 @@ class EventLive(EventPermissionRequiredMixin, TemplateView):
|
||||
})
|
||||
|
||||
|
||||
class EventTransferSession(EventPermissionRequiredMixin, TemplateView):
|
||||
permission = 'can_change_event_settings'
|
||||
template_name = 'pretixcontrol/event/transfer_session.html'
|
||||
|
||||
|
||||
class EventDelete(RecentAuthenticationRequiredMixin, EventPermissionRequiredMixin, FormView):
|
||||
permission = 'can_change_event_settings'
|
||||
template_name = 'pretixcontrol/event/delete.html'
|
||||
|
||||
Reference in New Issue
Block a user