all: fix left over references to error templates
This commit is contained in:
parent
b6326f399c
commit
e2f836feae
|
@ -1,26 +0,0 @@
|
||||||
{% extends 'login/base.html' %}
|
|
||||||
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% load utils %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
{{ block.super }}
|
|
||||||
<style>
|
|
||||||
.pf-icon {
|
|
||||||
font-size: 48px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block card %}
|
|
||||||
<header class="login-pf-header">
|
|
||||||
<h1>{% trans 'Forbidden' %}</h1>
|
|
||||||
</header>
|
|
||||||
<form>
|
|
||||||
{% if 'back' in request.GET %}
|
|
||||||
<a href="{% back %}" class="btn btn-primary btn-block btn-lg">{% trans 'Back' %}</a>
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
|
|
@ -1,26 +0,0 @@
|
||||||
{% extends 'login/base.html' %}
|
|
||||||
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% load utils %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
{{ block.super }}
|
|
||||||
<style>
|
|
||||||
.pf-icon {
|
|
||||||
font-size: 48px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block card %}
|
|
||||||
<header class="login-pf-header">
|
|
||||||
<h1>{% trans 'Not Found' %}</h1>
|
|
||||||
</header>
|
|
||||||
<form>
|
|
||||||
{% if 'back' in request.GET %}
|
|
||||||
<a href="{% back %}" class="btn btn-primary btn-block btn-lg">{% trans 'Back' %}</a>
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
|
|
@ -1,26 +0,0 @@
|
||||||
{% extends 'login/base.html' %}
|
|
||||||
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% load utils %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
{{ block.super }}
|
|
||||||
<style>
|
|
||||||
.pf-icon {
|
|
||||||
font-size: 48px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block card %}
|
|
||||||
<header class="login-pf-header">
|
|
||||||
<h1>{% trans 'Server Error' %}</h1>
|
|
||||||
</header>
|
|
||||||
<form>
|
|
||||||
{% if 'back' in request.GET %}
|
|
||||||
<a href="{% back %}" class="btn btn-primary btn-block btn-lg">{% trans 'Back' %}</a>
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
|
|
@ -4,16 +4,6 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load utils %}
|
{% load utils %}
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
{{ block.super }}
|
|
||||||
<style>
|
|
||||||
.pf-icon {
|
|
||||||
font-size: 48px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block card_title %}
|
{% block card_title %}
|
||||||
{% trans 'Bad Request' %}
|
{% trans 'Bad Request' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -29,29 +29,37 @@ class ServerErrorTemplateResponse(TemplateResponse, HttpResponseServerError):
|
||||||
class BadRequestView(TemplateView):
|
class BadRequestView(TemplateView):
|
||||||
"""Show Bad Request message"""
|
"""Show Bad Request message"""
|
||||||
|
|
||||||
|
extra_context = {"card_title": "Bad Request"}
|
||||||
|
|
||||||
response_class = BadRequestTemplateResponse
|
response_class = BadRequestTemplateResponse
|
||||||
template_name = "error/400.html"
|
template_name = "error/generic.html"
|
||||||
|
|
||||||
|
|
||||||
class ForbiddenView(TemplateView):
|
class ForbiddenView(TemplateView):
|
||||||
"""Show Forbidden message"""
|
"""Show Forbidden message"""
|
||||||
|
|
||||||
|
extra_context = {"card_title": "Forbidden"}
|
||||||
|
|
||||||
response_class = ForbiddenTemplateResponse
|
response_class = ForbiddenTemplateResponse
|
||||||
template_name = "error/403.html"
|
template_name = "error/generic.html"
|
||||||
|
|
||||||
|
|
||||||
class NotFoundView(TemplateView):
|
class NotFoundView(TemplateView):
|
||||||
"""Show Not Found message"""
|
"""Show Not Found message"""
|
||||||
|
|
||||||
|
extra_context = {"card_title": "Not Found"}
|
||||||
|
|
||||||
response_class = NotFoundTemplateResponse
|
response_class = NotFoundTemplateResponse
|
||||||
template_name = "error/404.html"
|
template_name = "error/generic.html"
|
||||||
|
|
||||||
|
|
||||||
class ServerErrorView(TemplateView):
|
class ServerErrorView(TemplateView):
|
||||||
"""Show Server Error message"""
|
"""Show Server Error message"""
|
||||||
|
|
||||||
|
extra_context = {"card_title": "Server Error"}
|
||||||
|
|
||||||
response_class = ServerErrorTemplateResponse
|
response_class = ServerErrorTemplateResponse
|
||||||
template_name = "error/500.html"
|
template_name = "error/generic.html"
|
||||||
|
|
||||||
# pylint: disable=useless-super-delegation
|
# pylint: disable=useless-super-delegation
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
|
|
|
@ -14,6 +14,7 @@ from passbook.core.views.utils import PermissionDeniedView
|
||||||
from passbook.lib.config import CONFIG
|
from passbook.lib.config import CONFIG
|
||||||
from passbook.lib.utils.reflection import class_to_path, path_to_class
|
from passbook.lib.utils.reflection import class_to_path, path_to_class
|
||||||
from passbook.lib.utils.urls import is_url_absolute
|
from passbook.lib.utils.urls import is_url_absolute
|
||||||
|
from passbook.lib.views import bad_request_message
|
||||||
from passbook.policies.engine import PolicyEngine
|
from passbook.policies.engine import PolicyEngine
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
@ -62,9 +63,7 @@ class AuthenticationView(UserPassesTestMixin, View):
|
||||||
f"match configured domain of '{config_domain}'."
|
f"match configured domain of '{config_domain}'."
|
||||||
)
|
)
|
||||||
LOGGER.warning(message)
|
LOGGER.warning(message)
|
||||||
return render(
|
return bad_request_message(self.request, message)
|
||||||
self.request, "error/400.html", context={"message": message}, status=400
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def handle_no_permission(self) -> HttpResponse:
|
def handle_no_permission(self) -> HttpResponse:
|
||||||
|
|
|
@ -27,4 +27,9 @@ class CreateAssignPermView(CreateView):
|
||||||
|
|
||||||
def bad_request_message(request: HttpRequest, message: str) -> HttpResponse:
|
def bad_request_message(request: HttpRequest, message: str) -> HttpResponse:
|
||||||
"""Return generic error page with message, with status code set to 400"""
|
"""Return generic error page with message, with status code set to 400"""
|
||||||
return render(request, "error/400.html", {"message": message}, status=400)
|
return render(
|
||||||
|
request,
|
||||||
|
"error/generic.html",
|
||||||
|
{"message": message, "card_title": "Bad Request",},
|
||||||
|
status=400,
|
||||||
|
)
|
||||||
|
|
Reference in a new issue