mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-12 06:42:16 -06:00
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Introduces `device_count`, `module_count` and `rack_count` filters to enable queries based on the existence and count of the associated device, module or rack instances. Updates forms, filtersets, and GraphQL schema to support these filters, along with tests for validation. Fixes #19523
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from django.apps import AppConfig
|
|
|
|
from netbox import denormalized
|
|
|
|
|
|
class DCIMConfig(AppConfig):
|
|
name = "dcim"
|
|
verbose_name = "DCIM"
|
|
|
|
def ready(self):
|
|
from netbox.models.features import register_models
|
|
from utilities.counters import connect_counters
|
|
from . import signals, search # noqa: F401
|
|
from .models import CableTermination, Device, DeviceType, ModuleType, RackType, VirtualChassis
|
|
|
|
# Register models
|
|
register_models(*self.get_models())
|
|
|
|
# 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',
|
|
})
|
|
|
|
# Register counters
|
|
connect_counters(Device, DeviceType, ModuleType, RackType, VirtualChassis)
|