Skip to content

Commit 35c7f0f

Browse files
committed
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
1 parent 9c38f1a commit 35c7f0f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

ietf/utils/response.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
from django.core.exceptions import PermissionDenied
5+
from django.utils.safestring import mark_safe
6+
7+
def permission_denied(request, msg):
8+
"A wrapper around the PermissionDenied exception"
9+
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
10+
raise PermissionDenied(mark_safe(msg))

0 commit comments

Comments
 (0)