mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-13 11:08:18 -06:00
Update endpoints of circuit terminations without creating a loop
Reverts "Break infinite loop by removing redundant update"
This commit is contained in:
parent
b5dfabf651
commit
1c902f6eaf
@ -1,4 +1,4 @@
|
||||
from django.db.models.signals import post_delete, post_save
|
||||
from django.db.models.signals import post_delete, post_save, pre_delete
|
||||
from django.dispatch import receiver
|
||||
from django.utils import timezone
|
||||
|
||||
@ -16,3 +16,18 @@ def update_circuit(instance, **kwargs):
|
||||
for circuit in circuits:
|
||||
circuit.last_updated = time
|
||||
circuit.save()
|
||||
|
||||
|
||||
@receiver(post_save, sender=CircuitTermination)
|
||||
def update_connected_endpoints(instance, created, **kwargs):
|
||||
if created:
|
||||
# Update all endpoints affected by this circuit
|
||||
endpoints = instance.circuit.get_related_endpoints()
|
||||
update_endpoints(endpoints)
|
||||
|
||||
|
||||
@receiver(post_delete, sender=CircuitTermination)
|
||||
def nullify_connected_endpoints(instance, **kwargs):
|
||||
# Update all endpoints affected by this circuit (through the other termination point)
|
||||
endpoints = instance.circuit.get_related_endpoints()
|
||||
update_endpoints(endpoints)
|
||||
|
Loading…
Reference in New Issue
Block a user