-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCKAN-373 fix: Add missing service file
- Loading branch information
1 parent
9d48c2e
commit 46ef27c
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.db import transaction | ||
|
||
|
||
|
||
def update_from_entities_on_deletion(connectivity_statement, deleted_entity_id): | ||
""" | ||
Updates the 'from_entities' for Layers that used the deleted entity. | ||
Scoped to the given ConnectivityStatement. | ||
""" | ||
from composer.models import Destination, Via | ||
|
||
# Filter affected layers within the same ConnectivityStatement | ||
affected_via_layers = Via.objects.filter( | ||
connectivity_statement=connectivity_statement, | ||
from_entities__id=deleted_entity_id | ||
) | ||
|
||
affected_destination_layers = Destination.objects.filter( | ||
connectivity_statement=connectivity_statement, | ||
from_entities__id=deleted_entity_id | ||
) | ||
|
||
# Update 'from_entities' by removing the deleted entity | ||
for via in affected_via_layers: | ||
via.from_entities.remove(deleted_entity_id) | ||
|
||
for destination in affected_destination_layers: | ||
destination.from_entities.remove(deleted_entity_id) |