From b158453c56f2549cf0a6d38cde1bd3d9561ec38b Mon Sep 17 00:00:00 2001 From: Jay Zeng Date: Fri, 20 Dec 2024 21:40:11 +0800 Subject: [PATCH] Show output of deletion result 204 status code will cause a removal of the output. --- rbac/internal/utils.py | 3 ++- rbac/internal/views.py | 2 +- tests/internal/test_views.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rbac/internal/utils.py b/rbac/internal/utils.py index c98044b5f..0d5a33244 100644 --- a/rbac/internal/utils.py +++ b/rbac/internal/utils.py @@ -21,6 +21,7 @@ from django.db import transaction from django.urls import resolve +from management.relation_replicator.logging_replicator import stringify_spicedb_relationship from management.relation_replicator.outbox_replicator import OutboxReplicator from management.relation_replicator.relation_replicator import PartitionKey, ReplicationEvent, ReplicationEventType @@ -81,5 +82,5 @@ def delete_bindings(bindings): ), ) bindings.delete() - info["relations"] = relations_to_remove + info["relations"] = [stringify_spicedb_relationship(relation) for relation in relations_to_remove] return info diff --git a/rbac/internal/views.py b/rbac/internal/views.py index 8ad80bbd2..90af20d3c 100644 --- a/rbac/internal/views.py +++ b/rbac/internal/views.py @@ -585,7 +585,7 @@ def list_or_delete_bindings_for_role(request, role_uuid): return HttpResponse(json.dumps(result), content_type="application/json", status=200) else: info = delete_bindings(bindings) - return HttpResponse(info, content_type="application/json", status=204) + return HttpResponse(json.dumps(info), status=200) def migration_resources(request): diff --git a/tests/internal/test_views.py b/tests/internal/test_views.py index 5d3d265ab..c4dd34824 100644 --- a/tests/internal/test_views.py +++ b/tests/internal/test_views.py @@ -644,7 +644,7 @@ def test_delete_bindings_by_role(self, replicate): f"/_private/api/utils/bindings/{self.role.uuid}/?mappings__role__is_system=True", **self.request.META, ) - self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + self.assertEqual(response.status_code, status.HTTP_200_OK) with self.assertRaises(BindingMapping.DoesNotExist): binding_mappings[0].refresh_from_db() binding_mappings[1].refresh_from_db()