Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCKAN-373 fix: Add missing service file #396

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions backend/composer/services/layers_service.py
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)
Loading