Skip to content

[Fixes #13159] Removing change ownership support from the /permissions endpoint #13179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions geonode/base/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,6 @@ def resource_service_permissions(self, request, pk, *args, **kwargs):
- Removes all the permissions (except owner and admin ones) from a Resource:
curl -v -X DELETE -u admin:admin -H "Content-Type: application/json" http://localhost:8000/api/v2/resources/<id>/permissions

- Changes the owner of a Resource:
curl -u admin:admin --location --request PUT 'http://localhost:8000/api/v2/resources/<id>/permissions' \
--header 'Content-Type: application/json' \
--data-raw '{"groups": [],"organizations": [],"users": [{"id": 1001,"permissions": "owner"}]}'

- Assigns View permissions to some users:
curl -u admin:admin --location --request PUT 'http://localhost:8000/api/v2/resources/<id>/permissions' \
--header 'Content-Type: application/json' \
Expand Down Expand Up @@ -606,6 +601,7 @@ def resource_service_permissions(self, request, pk, *args, **kwargs):
try:
perms_spec = PermSpec(resource.get_all_level_info(), resource)
request_params = request.data

if request.method == "GET":
return Response(perms_spec.compact)
elif request.method == "DELETE":
Expand All @@ -617,7 +613,9 @@ def resource_service_permissions(self, request, pk, *args, **kwargs):
input_params={"uuid": request_params.get("uuid", resource.uuid)},
)
elif request.method == "PUT":

perms_spec_compact = PermSpecCompact(request.data, resource)

if resource.dirty_state:
raise Exception("Cannot update if the resource is in dirty state")
resource.set_dirty_state()
Expand All @@ -628,15 +626,16 @@ def resource_service_permissions(self, request, pk, *args, **kwargs):
action="permissions",
input_params={
"uuid": request_params.get("uuid", resource.uuid),
"owner": request_params.get("owner", resource.owner.username),
"permissions": perms_spec_compact.extended,
"created": request_params.get("created", False),
},
)
elif request.method == "PATCH":

perms_spec_compact_patch = PermSpecCompact(request.data, resource)
perms_spec_compact_resource = PermSpecCompact(perms_spec.compact, resource)
perms_spec_compact_resource.merge(perms_spec_compact_patch)

if resource.dirty_state:
raise Exception("Cannot update if the resource is in dirty state")
resource.set_dirty_state()
Expand All @@ -647,7 +646,6 @@ def resource_service_permissions(self, request, pk, *args, **kwargs):
action="permissions",
input_params={
"uuid": request_params.get("uuid", resource.uuid),
"owner": request_params.get("owner", resource.owner.username),
"permissions": perms_spec_compact_resource.extended,
"created": request_params.get("created", False),
},
Expand Down
Loading