authentik/passbook/core/views/error.py

66 lines
1.8 KiB
Python
Raw Normal View History

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