This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/core/views/error.py

60 lines
1.6 KiB
Python
Raw Normal View History

2019-03-22 11:16:30 +00:00
"""passbook core error views"""
2019-12-31 11:51:16 +00:00
from django.http.response import (
HttpResponseBadRequest,
HttpResponseForbidden,
HttpResponseNotFound,
HttpResponseServerError,
)
2019-03-22 11:16:30 +00:00
from django.template.response import TemplateResponse
from django.views.generic import TemplateView
class BadRequestTemplateResponse(TemplateResponse, HttpResponseBadRequest):
"""Combine Template response with Http Code 400"""
2019-12-31 11:51:16 +00:00
2019-03-22 11:16:30 +00:00
class ForbiddenTemplateResponse(TemplateResponse, HttpResponseForbidden):
"""Combine Template response with Http Code 403"""
2019-12-31 11:51:16 +00:00
2019-03-22 11:16:30 +00:00
class NotFoundTemplateResponse(TemplateResponse, HttpResponseNotFound):
"""Combine Template response with Http Code 404"""
2019-12-31 11:51:16 +00:00
2019-03-22 11:16:30 +00:00
class ServerErrorTemplateResponse(TemplateResponse, HttpResponseServerError):
"""Combine Template response with Http Code 500"""
2019-12-31 11:51:16 +00:00
2019-03-22 11:16:30 +00:00
class BadRequestView(TemplateView):
"""Show Bad Request message"""
response_class = BadRequestTemplateResponse
2019-12-31 11:51:16 +00:00
template_name = "error/400.html"
2019-03-22 11:16:30 +00:00
class ForbiddenView(TemplateView):
"""Show Forbidden message"""
response_class = ForbiddenTemplateResponse
2019-12-31 11:51:16 +00:00
template_name = "error/403.html"
2019-03-22 11:16:30 +00:00
class NotFoundView(TemplateView):
"""Show Not Found message"""
response_class = NotFoundTemplateResponse
2019-12-31 11:51:16 +00:00
template_name = "error/404.html"
2019-03-22 11:16:30 +00:00
class ServerErrorView(TemplateView):
"""Show Server Error message"""
response_class = ServerErrorTemplateResponse
2019-12-31 11:51:16 +00:00
template_name = "error/500.html"
2019-03-22 11:16:30 +00:00
2019-04-09 15:26:53 +00:00
# pylint: disable=useless-super-delegation
def dispatch(self, *args, **kwargs):
"""Little wrapper so django accepts this function"""
return super().dispatch(*args, **kwargs)