Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
b8511f0e
Commit
b8511f0e
authored
Aug 29, 2018
by
Florent Chehab
Browse files
IsAdminOrReadOnly permission added
parent
1e57c4ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/models/tools/__init__.py
View file @
b8511f0e
...
...
@@ -4,3 +4,4 @@ from .validateWithRestFramework import validate_with_rest_framework # noqa: F40
from
.noDeleteIfNotAdmin
import
NoDeleteIfNotAdmin
# noqa: F401
from
.isOwner
import
IsOwner
# noqa: F401
from
.noDelete
import
NoDelete
# noqa: F401
from
.isAdminOrReadOnly
import
IsAdminOrReadOnly
# noqa: F401
backend/models/tools/isAdminOrReadOnly.py
0 → 100644
View file @
b8511f0e
from
rest_framework
import
permissions
class
IsAdminOrReadOnly
(
permissions
.
BasePermission
):
def
has_permission
(
self
,
request
,
view
):
if
request
.
user
.
is_staff
:
return
True
if
request
.
method
in
permissions
.
SAFE_METHODS
:
return
True
else
:
return
False
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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