diff --git a/arches/app/models/graph.py b/arches/app/models/graph.py index 1ec92bf65d..4c43c1ec25 100644 --- a/arches/app/models/graph.py +++ b/arches/app/models/graph.py @@ -2449,6 +2449,7 @@ def update_from_editable_future_graph(self, editable_future_graph): if card["source_identifier_id"] } + # update cards_x_nodes_x_widgets for serialized_card_x_node_x_widget in serialized_editable_future_graph[ "cards_x_nodes_x_widgets" ]: @@ -2470,6 +2471,7 @@ def update_from_editable_future_graph(self, editable_future_graph): if updated_node_id: serialized_card_x_node_x_widget["node_id"] = updated_node_id + # update cards for serialized_card in serialized_editable_future_graph["cards"]: if serialized_card["source_identifier_id"]: serialized_card["cardid"] = serialized_card["source_identifier_id"] @@ -2483,6 +2485,7 @@ def update_from_editable_future_graph(self, editable_future_graph): serialized_card["graph_id"] = serialized_source_graph["graphid"] + # update nodes for serialized_node in serialized_editable_future_graph["nodes"]: if serialized_node["source_identifier_id"]: serialized_node["nodeid"] = serialized_node["source_identifier_id"] @@ -2496,6 +2499,7 @@ def update_from_editable_future_graph(self, editable_future_graph): serialized_node["graph_id"] = serialized_source_graph["graphid"] + # update nodegroups for serialized_nodegroup in serialized_editable_future_graph["nodegroups"]: updated_nodegroup_id = node_id_to_node_source_identifier_id.get( serialized_nodegroup["nodegroupid"] @@ -2509,6 +2513,7 @@ def update_from_editable_future_graph(self, editable_future_graph): if updated_nodegroup_id: serialized_nodegroup["parentnodegroup_id"] = updated_parent_nodegroup_id + # update edges for serialized_edge in serialized_editable_future_graph["edges"]: if serialized_edge["source_identifier_id"]: serialized_edge["edgeid"] = serialized_edge["source_identifier_id"] @@ -2528,6 +2533,7 @@ def update_from_editable_future_graph(self, editable_future_graph): serialized_edge["graph_id"] = serialized_source_graph["graphid"] + # update root node serialized_editable_future_graph["root"]["graph_id"] = serialized_source_graph[ "graphid" ] @@ -2536,6 +2542,7 @@ def update_from_editable_future_graph(self, editable_future_graph): ) serialized_editable_future_graph["root"]["source_identifier_id"] = None + # update graph data serialized_editable_future_graph["graphid"] = serialized_source_graph["graphid"] serialized_editable_future_graph["has_unpublished_changes"] = False serialized_editable_future_graph["resource_instance_lifecycle_id"] = ( @@ -2543,6 +2550,7 @@ def update_from_editable_future_graph(self, editable_future_graph): ) serialized_editable_future_graph["source_identifier_id"] = None + # update permissions serialized_editable_future_graph["group_permissions"] = { key: value for key, value in serialized_source_graph["group_permissions"].items() diff --git a/tests/models/graph_tests.py b/tests/models/graph_tests.py index c22909121a..ef7968caa9 100644 --- a/tests/models/graph_tests.py +++ b/tests/models/graph_tests.py @@ -1765,6 +1765,9 @@ def test_deleting_source_graph_deletes_editable_future_graph_and_all_related_mod edge_count_before = models.Edge.objects.count() card_count_before = models.CardModel.objects.count() card_x_node_x_widget_count_before = models.CardXNodeXWidget.objects.count() + resource_2_resource_constraints_count_before = ( + models.Resource2ResourceConstraint.objects.count() + ) source_graph = Graph.new(name="TEST RESOURCE", is_resource=True, author="TEST") source_graph.save() @@ -1786,6 +1789,9 @@ def test_deleting_source_graph_deletes_editable_future_graph_and_all_related_mod edge_count_after = models.Edge.objects.count() card_count_after = models.CardModel.objects.count() card_x_node_x_widget_count_after = models.CardXNodeXWidget.objects.count() + resource_2_resource_constraints_count_after = ( + models.Resource2ResourceConstraint.objects.count() + ) self.assertEqual(nodegroup_count_before, nodegroup_count_after) self.assertEqual(node_count_before, node_count_after) @@ -1794,6 +1800,10 @@ def test_deleting_source_graph_deletes_editable_future_graph_and_all_related_mod self.assertEqual( card_x_node_x_widget_count_before, card_x_node_x_widget_count_after ) + self.assertEqual( + resource_2_resource_constraints_count_before, + resource_2_resource_constraints_count_after, + ) def test_revert_editable_future_graph(self): source_graph = Graph.new(name="TEST RESOURCE", is_resource=True, author="TEST") @@ -2160,7 +2170,7 @@ def test_update_from_editable_future_graph_does_not_affect_resources(self): self.assertEqual(serialized_resource, serialized_resource_from_database) self.assertEqual(serialized_tile, serialized_tile_from_database) - def test_foo(self): + def test_placing_node_in_separate_card_does_not_pollute_database(self): source_graph = Graph.new(name="TEST RESOURCE", is_resource=True, author="TEST") source_graph.save() editable_future_graph = source_graph.create_editable_future_graph()