lib: use TemplateResponse for bad_request_message
This commit is contained in:
parent
6fd19c0a37
commit
fc9f86cccc
|
@ -27,7 +27,7 @@ class TestUtilViews(TestCase):
|
||||||
request = self.factory.get("something")
|
request = self.factory.get("something")
|
||||||
response = LoadingView.as_view(target_url="somestring")(request)
|
response = LoadingView.as_view(target_url="somestring")(request)
|
||||||
response.render()
|
response.render()
|
||||||
self.assertIn("somestring", response.content.decode("utf-8"))
|
self.assertIn("somestring", response.rendered_content)
|
||||||
|
|
||||||
def test_permission_denied_view(self):
|
def test_permission_denied_view(self):
|
||||||
"""Test PermissionDeniedView"""
|
"""Test PermissionDeniedView"""
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""passbook helper views"""
|
"""passbook helper views"""
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest
|
||||||
from django.shortcuts import render
|
from django.template.response import TemplateResponse
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import CreateView
|
from django.views.generic import CreateView
|
||||||
from guardian.shortcuts import assign_perm
|
from guardian.shortcuts import assign_perm
|
||||||
|
|
||||||
|
@ -25,11 +26,11 @@ class CreateAssignPermView(CreateView):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def bad_request_message(request: HttpRequest, message: str) -> HttpResponse:
|
def bad_request_message(request: HttpRequest, message: str) -> TemplateResponse:
|
||||||
"""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(
|
return TemplateResponse(
|
||||||
request,
|
request,
|
||||||
"error/generic.html",
|
"error/generic.html",
|
||||||
{"message": message, "card_title": "Bad Request",},
|
{"message": message, "card_title": _("Bad Request")},
|
||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
Reference in New Issue