mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Fixes #817: Update last_updated time of a circuit when editing a child termination
This commit is contained in:
parent
476cbf17f6
commit
d36923e47d
@ -0,0 +1 @@
|
|||||||
|
default_app_config = 'circuits.apps.CircuitsConfig'
|
9
netbox/circuits/apps.py
Normal file
9
netbox/circuits/apps.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class CircuitsConfig(AppConfig):
|
||||||
|
name = "circuits"
|
||||||
|
verbose_name = "Circuits"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
import circuits.signals
|
13
netbox/circuits/signals.py
Normal file
13
netbox/circuits/signals.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from django.db.models.signals import post_delete, post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from .models import Circuit, CircuitTermination
|
||||||
|
|
||||||
|
|
||||||
|
@receiver((post_save, post_delete), sender=CircuitTermination)
|
||||||
|
def update_circuit(instance, **kwargs):
|
||||||
|
"""
|
||||||
|
When a CircuitTermination has been modified, update the last_updated time of its parent Circuit.
|
||||||
|
"""
|
||||||
|
Circuit.objects.filter(pk=instance.circuit_id).update(last_updated=timezone.now())
|
Loading…
Reference in New Issue
Block a user