Coverage for backend/django/flowsheetInternals/graphicData/logic/ungroup.py: 100%
21 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
1from typing import List
2from flowsheetInternals.graphicData.models.groupingModel import Grouping, GraphicObject
3from flowsheetInternals.unitops.models.SimulationObject import SimulationObject
4from flowsheetInternals.unitops.models.delete_factory import DeleteFactory
7def ungroup(group: Grouping):
8 #groups parent object is set to none
9 parent_group = group.get_parent_group()
11 contained_objects : List[GraphicObject] = group.graphicObjects.all()
13 for graphic_object in contained_objects:
14 # add all graphic objects to the parent group
15 simulationObject : SimulationObject = graphic_object.simulationObject
16 # See if a graphic object already exists within the parent group (should only happen for streams)
17 # If there is, delete the top level graphic object so that positioning is maintained from the grouped one.
18 parent_group_graphic_object = simulationObject.graphicObject.filter(group=parent_group).first()
19 if parent_group_graphic_object:
20 parent_group_graphic_object.delete()
22 parent_group.update_internal_graphic_objects(contained_objects)
24 DeleteFactory.delete_object(group.simulationObject)
26 # update zones in StreamDataEntry
27 for graphic_object in contained_objects:
28 simulationObject : SimulationObject = graphic_object.simulationObject
29 if simulationObject.is_stream():
30 continue
31 for stream_data_entry in simulationObject.StreamDataEntries.all():
32 stream_data_entry.group = parent_group
33 stream_data_entry.save()