Skip to content

Commit

Permalink
Use custom error layout for shop offline
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Jan 3, 2024
1 parent d5f2f0e commit 809b971
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
28 changes: 28 additions & 0 deletions src/pretix/presale/templates/pretixpresale/event/offline.html
Original file line number Diff line number Diff line change
@@ -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 %}
10 changes: 5 additions & 5 deletions src/pretix/presale/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@
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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 809b971

Please sign in to comment.