diff --git a/passbook/core/tests/test_views_utils.py b/passbook/core/tests/test_views_utils.py index 3d0083425..e9c8d6af9 100644 --- a/passbook/core/tests/test_views_utils.py +++ b/passbook/core/tests/test_views_utils.py @@ -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""" diff --git a/passbook/lib/views.py b/passbook/lib/views.py index cb537b826..c816b70fe 100644 --- a/passbook/lib/views.py +++ b/passbook/lib/views.py @@ -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, )