Bases: permissions.BasePermission
Custom permission to only allow owners of an object to edit it.
Source code in users/permissions.py
| class IsOwner(permissions.BasePermission):
"""
Custom permission to only allow owners of an object to edit it.
"""
def has_permission(self, request, view):
return request.user and request.user.is_authenticated
def has_object_permission(self, request, view, obj):
return obj.creator == request.user or request.user.is_superuser
|
has_object_permission(request, view, obj)
Source code in users/permissions.py
| def has_object_permission(self, request, view, obj):
return obj.creator == request.user or request.user.is_superuser
|
has_permission(request, view)
Source code in users/permissions.py
| def has_permission(self, request, view):
return request.user and request.user.is_authenticated
|