mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-01 07:03:22 +02:00
Move cache update logic from signal to model save method and track original values to properly clear old cache when circuit_id or term_side changes. Add comprehensive tests for all cache update scenarios. Fixes #21686
18 lines
534 B
Python
18 lines
534 B
Python
from django.db.models.signals import post_delete, post_save
|
|
from django.dispatch import receiver
|
|
|
|
from dcim.signals import rebuild_paths
|
|
|
|
from .models import CircuitTermination
|
|
|
|
|
|
@receiver((post_save, post_delete), sender=CircuitTermination)
|
|
def rebuild_cablepaths(instance, raw=False, **kwargs):
|
|
"""
|
|
Rebuild any CablePaths which traverse the peer CircuitTermination.
|
|
"""
|
|
if not raw:
|
|
peer_termination = instance.get_peer_termination()
|
|
if peer_termination:
|
|
rebuild_paths([peer_termination])
|