Add admin only or read only permission for api

This commit is contained in:
Aroy-Art 2025-01-03 22:42:33 +01:00
parent 9a3a1cf60b
commit fea0b8604d
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -13,3 +13,10 @@ class AdminOnly(permissions.BasePermission):
def has_permission(self, request, view):
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)