Quellcode durchsuchen

Fixes #9788: Ensure denormalized fields on CableTermination are kept in sync with related objects

jeremystretch vor 3 Jahren
Ursprung
Commit
d3a567a2f5
2 geänderte Dateien mit 18 neuen und 1 gelöschten Zeilen
  1. 1 0
      docs/release-notes/version-3.3.md
  2. 17 1
      netbox/dcim/apps.py

+ 1 - 0
docs/release-notes/version-3.3.md

@@ -104,6 +104,7 @@ Custom field UI visibility has no impact on API operation.
 * [#9730](https://github.com/netbox-community/netbox/issues/9730) - Fix validation error when creating a new cable via UI form
 * [#9730](https://github.com/netbox-community/netbox/issues/9730) - Fix validation error when creating a new cable via UI form
 * [#9733](https://github.com/netbox-community/netbox/issues/9733) - Handle split paths during trace when fanning out to front ports with differing cables
 * [#9733](https://github.com/netbox-community/netbox/issues/9733) - Handle split paths during trace when fanning out to front ports with differing cables
 * [#9765](https://github.com/netbox-community/netbox/issues/9765) - Report correct segment count under cable trace UI view
 * [#9765](https://github.com/netbox-community/netbox/issues/9765) - Report correct segment count under cable trace UI view
+* [#9788](https://github.com/netbox-community/netbox/issues/9788) - Ensure denormalized fields on CableTermination are kept in sync with related objects
 * [#9789](https://github.com/netbox-community/netbox/issues/9789) - Fix rendering of cable traces ending at provider networks
 * [#9789](https://github.com/netbox-community/netbox/issues/9789) - Fix rendering of cable traces ending at provider networks
 * [#9794](https://github.com/netbox-community/netbox/issues/9794) - Fix link to connect a rear port to a circuit termination
 * [#9794](https://github.com/netbox-community/netbox/issues/9794) - Fix link to connect a rear port to a circuit termination
 * [#9818](https://github.com/netbox-community/netbox/issues/9818) - Fix circuit side selection when connecting a cable to a circuit termination
 * [#9818](https://github.com/netbox-community/netbox/issues/9818) - Fix circuit side selection when connecting a cable to a circuit termination

+ 17 - 1
netbox/dcim/apps.py

@@ -1,10 +1,26 @@
 from django.apps import AppConfig
 from django.apps import AppConfig
 
 
+from netbox import denormalized
+
 
 
 class DCIMConfig(AppConfig):
 class DCIMConfig(AppConfig):
     name = "dcim"
     name = "dcim"
     verbose_name = "DCIM"
     verbose_name = "DCIM"
 
 
     def ready(self):
     def ready(self):
-
         import dcim.signals
         import dcim.signals
+        from .models import CableTermination
+
+        # Register denormalized fields
+        denormalized.register(CableTermination, '_device', {
+            '_rack': 'rack',
+            '_location': 'location',
+            '_site': 'site',
+        })
+        denormalized.register(CableTermination, '_rack', {
+            '_location': 'location',
+            '_site': 'site',
+        })
+        denormalized.register(CableTermination, '_location', {
+            '_site': 'site',
+        })