Use custom error layout for shop offline

This commit is contained in:
Raphael Michel
2024-01-03 11:01:19 +01:00
parent d5f2f0e3af
commit 809b971b4f
2 changed files with 33 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
{% extends "error.html" %}
{% load i18n %}
{% load static %}
{% block title %}{% trans "Shop offline" %}{% endblock %}
{% block content %}
<i class="fa fa-fw fa-power-off big-icon"></i>
<div class="error-details">
<h1>{% trans "Shop offline" %}</h1>
<p>{% trans "This ticket shop is currently turned off." %}</p>
<p>{% trans "It is only accessible to authenticated team members." %}</p>
<p>{% trans "Please try again later." %}</p>
<p class="links">
<a id='goback' href='#'>{% trans "Take a step back" %}</a>
&middot; <a id='reload' href='#'>{% trans "Try again" %}</a>
</p>
{% if request.user.is_staff and not staff_session %}
<form action="{% url 'control:user.sudo' %}?next={{ request.path|add:"?"|add:request.GET.urlencode|urlencode }}" method="post">
<p>
{% csrf_token %}
<button type="submit" class="btn btn-default" id="button-sudo">
<i class="fa fa-id-card"></i> {% trans "Admin mode" %}
</button>
</p>
</form>
{% endif %}
<img src="{% static "pretixbase/img/pretix-logo.svg" %}" class="logo"/>
</div>
{% endblock %}

View File

@@ -38,17 +38,16 @@ from importlib import import_module
from urllib.parse import urljoin
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.http import Http404
from django.http import Http404, HttpResponseForbidden
from django.middleware.csrf import rotate_token
from django.template import loader
from django.template.response import TemplateResponse
from django.urls import resolve
from django.utils.crypto import constant_time_compare
from django.utils.functional import SimpleLazyObject
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django.views.defaults import permission_denied
from django_scopes import scope
from pretix.base.middleware import LocaleMiddleware
@@ -325,8 +324,9 @@ def _detect_event(request, require_live=True, require_plugin=None):
if not can_access:
# Directly construct view instead of just calling `raise` since this case is so common that we
# don't want it to show in our log files.
return permission_denied(
request, PermissionDenied(_('The selected ticket shop is currently not available.'))
template = loader.get_template("pretixpresale/event/offline.html")
return HttpResponseForbidden(
template.render(request=request)
)
if require_plugin: