Skip to content

Commit

Permalink
Rename delegated_obj to permission_src for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Jan 22, 2024
1 parent 62a441d commit 16ed977
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions api/cedar_metadata_records/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def has_object_permission(self, request, view, obj):

auth = get_user_auth(request)

delegated_object = obj.guid.referent
if isinstance(delegated_object, BaseFileNode):
delegated_object = delegated_object.target
elif not isinstance(delegated_object, (Node, Registration)):
permission_source = obj.guid.referent
if isinstance(permission_source, BaseFileNode):
permission_source = permission_source.target
elif not isinstance(permission_source, (Node, Registration)):
return False

if request.method in permissions.SAFE_METHODS:
is_public = delegated_object.is_public and obj.is_published
return is_public or delegated_object.can_view(auth)
return delegated_object.can_edit(auth)
is_public = permission_source.is_public and obj.is_published
return is_public or permission_source.can_view(auth)
return permission_source.can_edit(auth)

0 comments on commit 16ed977

Please sign in to comment.