lib: add helper method for 400 response with message
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
"""passbook helper views"""
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import CreateView
|
||||
from guardian.shortcuts import assign_perm
|
||||
|
||||
@ -22,3 +23,8 @@ class CreateAssignPermView(CreateView):
|
||||
)
|
||||
assign_perm(full_permission, self.request.user, self.object)
|
||||
return response
|
||||
|
||||
|
||||
def bad_request_message(request: HttpRequest, message: str) -> HttpResponse:
|
||||
"""Return generic error page with message, with status code set to 400"""
|
||||
return render(request, "error/400.html", {"message": message}, status=400)
|
||||
|
Reference in New Issue
Block a user