From c8b2fcf5478efe7ef5b2254c90a2cda0c7ec2a6d Mon Sep 17 00:00:00 2001 From: Galen Date: Wed, 17 Apr 2024 15:24:50 -0700 Subject: [PATCH] returns deleted_count from graph.delete_instances(), renames var, re #10781 --- arches/app/models/graph.py | 3 +++ arches/app/views/graph.py | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arches/app/models/graph.py b/arches/app/models/graph.py index 57018ef77c1..485fdea0525 100644 --- a/arches/app/models/graph.py +++ b/arches/app/models/graph.py @@ -570,12 +570,15 @@ def delete_instances(self, verbose=False): """ if verbose is True: bar = pyprind.ProgBar(Resource.objects.filter(graph_id=self.graphid).count()) + delete_count = 0 for resource in Resource.objects.filter(graph_id=self.graphid): resource.delete() + delete_count += 1 if verbose is True: bar.update() if verbose is True: print(bar) + return delete_count def get_tree(self, root=None): """ diff --git a/arches/app/views/graph.py b/arches/app/views/graph.py index 0dfc0c8dacb..8f736a072de 100644 --- a/arches/app/views/graph.py +++ b/arches/app/views/graph.py @@ -469,12 +469,11 @@ def delete(self, request, graphid): elif self.action == "delete_instances": try: graph = Graph.objects.get(graphid=graphid) - resource_count = models.ResourceInstance.objects.filter(graph_id=graphid).count() - graph.delete_instances() + deleted_resource_count = graph.delete_instances() return JSONResponse( { "success": True, - "message": f"All {resource_count} resources associated with the Model '{graph.name}' have been successfully deleted.", + "message": f"All {deleted_resource_count} resources associated with the Model '{graph.name}' have been successfully deleted.", "title": "Resources Successfully Deleted.", } )