lib: use TemplateResponse for bad_request_message

This commit is contained in:
Jens Langhammer 2020-05-11 14:08:04 +02:00
parent 6fd19c0a37
commit fc9f86cccc
2 changed files with 7 additions and 6 deletions

View file

@ -27,7 +27,7 @@ class TestUtilViews(TestCase):
request = self.factory.get("something")
response = LoadingView.as_view(target_url="somestring")(request)
response.render()
self.assertIn("somestring", response.content.decode("utf-8"))
self.assertIn("somestring", response.rendered_content)
def test_permission_denied_view(self):
"""Test PermissionDeniedView"""

View file

@ -1,6 +1,7 @@
"""passbook helper views"""
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.http import HttpRequest
from django.template.response import TemplateResponse
from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView
from guardian.shortcuts import assign_perm
@ -25,11 +26,11 @@ class CreateAssignPermView(CreateView):
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 render(
return TemplateResponse(
request,
"error/generic.html",
{"message": message, "card_title": "Bad Request",},
{"message": message, "card_title": _("Bad Request")},
status=400,
)