Commit b8511f0e authored by Florent Chehab's avatar Florent Chehab
Browse files

IsAdminOrReadOnly permission added

parent 1e57c4ac
......@@ -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
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
return False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment