mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 17:39:48 +03:00
added IsAdminUserOrReadOnly permission
This commit is contained in:
parent
e4947c855a
commit
96ea55a000
|
@ -168,6 +168,20 @@ class IsAuthenticatedOrReadOnly(BasePermission):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class IsAdminUserOrReadOnly(BasePermission):
|
||||||
|
"""
|
||||||
|
The request is authenticated as a admin user, or is a read-only request.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return bool(
|
||||||
|
request.method in SAFE_METHODS or
|
||||||
|
request.user and
|
||||||
|
request.user.is_staff
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DjangoModelPermissions(BasePermission):
|
class DjangoModelPermissions(BasePermission):
|
||||||
"""
|
"""
|
||||||
The request is authenticated using `django.contrib.auth` permissions.
|
The request is authenticated using `django.contrib.auth` permissions.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user