Add admin only or read only permission for api
This commit is contained in:
parent
9a3a1cf60b
commit
fea0b8604d
1 changed files with 7 additions and 0 deletions
|
@ -13,3 +13,10 @@ class AdminOnly(permissions.BasePermission):
|
||||||
def has_permission(self, request, view):
|
def has_permission(self, request, view):
|
||||||
return check_admin(request.user)
|
return check_admin(request.user)
|
||||||
|
|
||||||
|
|
||||||
|
class AdminOnlyOrReadOnly(permissions.BasePermission):
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
if request.method in permissions.SAFE_METHODS:
|
||||||
|
return True
|
||||||
|
return check_admin(request.user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue