Added a utility function around the PermissionDenied exception, in order to easily be able to provide relevant information to the 403 template.

- Legacy-Id: 18332
This commit is contained in:
Henrik Levkowetz 2020-07-31 12:35:00 +00:00
parent 9c38f1a670
commit 35c7f0fd9d

10
ietf/utils/response.py Normal file
View file

@ -0,0 +1,10 @@
# Copyright The IETF Trust 2020, All Rights Reserved
# -*- coding: utf-8 -*-
from django.core.exceptions import PermissionDenied
from django.utils.safestring import mark_safe
def permission_denied(request, msg):
"A wrapper around the PermissionDenied exception"
msg += " <br/>You can <a href='/accounts/login?next=%s'><u>Log in</u></a> if you have that role but aren't logged in." % request.path
raise PermissionDenied(mark_safe(msg))