all: fix left over references to error templates

This commit is contained in:
Jens Langhammer 2020-02-21 15:04:37 +01:00
parent b6326f399c
commit e2f836feae
7 changed files with 20 additions and 96 deletions

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -4,16 +4,6 @@
{% load i18n %}
{% load utils %}
{% block head %}
{{ block.super }}
<style>
.pf-icon {
font-size: 48px;
text-align: center;
}
</style>
{% endblock %}
{% block card_title %}
{% trans 'Bad Request' %}
{% endblock %}

View File

@ -29,29 +29,37 @@ class ServerErrorTemplateResponse(TemplateResponse, HttpResponseServerError):
class BadRequestView(TemplateView):
"""Show Bad Request message"""
extra_context = {"card_title": "Bad Request"}
response_class = BadRequestTemplateResponse
template_name = "error/400.html"
template_name = "error/generic.html"
class ForbiddenView(TemplateView):
"""Show Forbidden message"""
extra_context = {"card_title": "Forbidden"}
response_class = ForbiddenTemplateResponse
template_name = "error/403.html"
template_name = "error/generic.html"
class NotFoundView(TemplateView):
"""Show Not Found message"""
extra_context = {"card_title": "Not Found"}
response_class = NotFoundTemplateResponse
template_name = "error/404.html"
template_name = "error/generic.html"
class ServerErrorView(TemplateView):
"""Show Server Error message"""
extra_context = {"card_title": "Server Error"}
response_class = ServerErrorTemplateResponse
template_name = "error/500.html"
template_name = "error/generic.html"
# pylint: disable=useless-super-delegation
def dispatch(self, *args, **kwargs):

View File

@ -14,6 +14,7 @@ from passbook.core.views.utils import PermissionDeniedView
from passbook.lib.config import CONFIG
from passbook.lib.utils.reflection import class_to_path, path_to_class
from passbook.lib.utils.urls import is_url_absolute
from passbook.lib.views import bad_request_message
from passbook.policies.engine import PolicyEngine
LOGGER = get_logger()
@ -62,9 +63,7 @@ class AuthenticationView(UserPassesTestMixin, View):
f"match configured domain of '{config_domain}'."
)
LOGGER.warning(message)
return render(
self.request, "error/400.html", context={"message": message}, status=400
)
return bad_request_message(self.request, message)
return None
def handle_no_permission(self) -> HttpResponse:

View File

@ -27,4 +27,9 @@ class CreateAssignPermView(CreateView):
def bad_request_message(request: HttpRequest, message: str) -> HttpResponse:
"""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,
)