Bases: permissions.BasePermission
Custom permission to only allow owners of an object to edit it.
Source code in reports/permissions.py
18
19
20
21
22
23
24
25
26
27 | class CanEditReport(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: Report):
return obj.can_edit(request.user)
|
has_object_permission(request, view, obj)
Source code in reports/permissions.py
| def has_object_permission(self, request, view, obj: Report):
return obj.can_edit(request.user)
|
has_permission(request, view)
Source code in reports/permissions.py
| def has_permission(self, request, view):
return request.user and request.user.is_authenticated
|