restricting access using permissions, first step
This commit is contained in:
parent
be4df3a1f7
commit
d881679b7e
7 changed files with 79 additions and 14 deletions
11
issue/shortcuts.py
Normal file
11
issue/shortcuts.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from django.contrib.auth.views import redirect_to_login
|
||||
|
||||
|
||||
def permission_granted_or_login(request, perm):
|
||||
|
||||
if hasattr(request, 'project'):
|
||||
project = request.project
|
||||
else:
|
||||
project = None
|
||||
if not request.user.has_perm(perm, project):
|
||||
return redirect_to_login(request.build_absolute_uri())
|
Loading…
Add table
Add a link
Reference in a new issue