Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Re2o
re2o
Commits
9b3bc1d0
Commit
9b3bc1d0
authored
Sep 06, 2019
by
klafyvel
Browse files
ACL for applications.
parent
225731b2
Changes
6
Hide whitespace changes
Inline
Side-by-side
api/acl.py
View file @
9b3bc1d0
...
...
@@ -33,7 +33,7 @@ from django.utils.translation import ugettext as _
def
_create_api_permission
():
"""Creates the 'use_api' permission if not created.
The 'use_api' is a fake permission in the sense it is not associated with an
existing model and this ensure the permission is created every time this file
is imported.
...
...
@@ -70,6 +70,7 @@ def can_view(user):
'app_label'
:
settings
.
API_CONTENT_TYPE_APP_LABEL
,
'codename'
:
settings
.
API_PERMISSION_CODENAME
}
can
=
user
.
has_perm
(
'%(app_label)s.%(codename)s'
%
kwargs
)
permission
=
'%(app_label)s.%(codename)s'
%
kwargs
can
=
user
.
has_perm
(
permission
)
return
can
,
None
if
can
else
_
(
"You don't have the right to see this"
" application."
)
" application."
)
,
(
permission
,)
cotisations/acl.py
View file @
9b3bc1d0
...
...
@@ -40,7 +40,11 @@ def can_view(user):
"""
can
=
user
.
has_module_perms
(
'cotisations'
)
if
can
:
return
can
,
None
return
can
,
None
,
(
'cotisations'
,)
else
:
return
can
,
_
(
"You don't have the right to view this application."
)
return
(
can
,
_
(
"You don't have the right to view this application."
),
(
'cotisations'
,)
)
machines/acl.py
View file @
9b3bc1d0
...
...
@@ -39,5 +39,10 @@ def can_view(user):
viewing is granted and msg is a message (can be None).
"""
can
=
user
.
has_module_perms
(
'machines'
)
return
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
)
return
(
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
),
(
'machines'
,)
)
preferences/acl.py
View file @
9b3bc1d0
...
...
@@ -39,6 +39,10 @@ def can_view(user):
viewing is granted and msg is a message (can be None).
"""
can
=
user
.
has_module_perms
(
'preferences'
)
return
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
)
return
(
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
),
(
'preferences'
,)
)
topologie/acl.py
View file @
9b3bc1d0
...
...
@@ -39,6 +39,10 @@ def can_view(user):
viewing is granted and msg is a message (can be None).
"""
can
=
user
.
has_module_perms
(
'topologie'
)
return
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
)
return
(
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
),
(
'topologie'
,)
)
users/acl.py
View file @
9b3bc1d0
...
...
@@ -38,6 +38,10 @@ def can_view(user):
viewing is granted and msg is a message (can be None).
"""
can
=
user
.
has_module_perms
(
'users'
)
return
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
)
return
(
can
,
None
if
can
else
_
(
"You don't have the right to view this"
" application."
),
(
'users'
,)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment