From 48e5b395b276f0fced2748125d24b2ad7d1e89d7 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 25 Jan 2023 16:20:52 -0500 Subject: [PATCH] Standardize linking to related objects in tables --- netbox/circuits/tables/circuits.py | 4 +++- netbox/dcim/tables/devices.py | 3 +++ netbox/dcim/tables/devicetypes.py | 1 - netbox/dcim/tables/racks.py | 6 +++++- netbox/dcim/views.py | 10 ++++++++-- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/netbox/circuits/tables/circuits.py b/netbox/circuits/tables/circuits.py index 477f9c1ab..b3f62d5fc 100644 --- a/netbox/circuits/tables/circuits.py +++ b/netbox/circuits/tables/circuits.py @@ -28,7 +28,9 @@ class CircuitTypeTable(NetBoxTable): tags = columns.TagColumn( url_name='circuits:circuittype_list' ) - circuit_count = tables.Column( + circuit_count = columns.LinkedCountColumn( + viewname='circuits:circuit_list', + url_params={'type_id': 'pk'}, verbose_name='Circuits' ) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 730309156..904e96b83 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -107,6 +107,9 @@ class PlatformTable(NetBoxTable): name = tables.Column( linkify=True ) + manufacturer = tables.Column( + linkify=True + ) device_count = columns.LinkedCountColumn( viewname='dcim:device_list', url_params={'platform_id': 'pk'}, diff --git a/netbox/dcim/tables/devicetypes.py b/netbox/dcim/tables/devicetypes.py index 9bcc9c47f..dff697588 100644 --- a/netbox/dcim/tables/devicetypes.py +++ b/netbox/dcim/tables/devicetypes.py @@ -49,7 +49,6 @@ class ManufacturerTable(ContactsColumnMixin, NetBoxTable): url_params={'manufacturer_id': 'pk'}, verbose_name='Platforms' ) - slug = tables.Column() tags = columns.TagColumn( url_name='dcim:manufacturer_list' ) diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py index cb9aae6fd..657754017 100644 --- a/netbox/dcim/tables/racks.py +++ b/netbox/dcim/tables/racks.py @@ -19,7 +19,11 @@ __all__ = ( class RackRoleTable(NetBoxTable): name = tables.Column(linkify=True) - rack_count = tables.Column(verbose_name='Racks') + rack_count = columns.LinkedCountColumn( + viewname='dcim:rack_list', + url_params={'role_id': 'pk'}, + verbose_name='Racks' + ) color = columns.ColorColumn() tags = columns.TagColumn( url_name='dcim:rackrole_list' diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 693b7c2d2..4683a6084 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -843,7 +843,10 @@ class ManufacturerBulkImportView(generic.BulkImportView): class ManufacturerBulkEditView(generic.BulkEditView): queryset = Manufacturer.objects.annotate( - devicetype_count=count_related(DeviceType, 'manufacturer') + devicetype_count=count_related(DeviceType, 'manufacturer'), + moduletype_count=count_related(ModuleType, 'manufacturer'), + inventoryitem_count=count_related(InventoryItem, 'manufacturer'), + platform_count=count_related(Platform, 'manufacturer') ) filterset = filtersets.ManufacturerFilterSet table = tables.ManufacturerTable @@ -852,7 +855,10 @@ class ManufacturerBulkEditView(generic.BulkEditView): class ManufacturerBulkDeleteView(generic.BulkDeleteView): queryset = Manufacturer.objects.annotate( - devicetype_count=count_related(DeviceType, 'manufacturer') + devicetype_count=count_related(DeviceType, 'manufacturer'), + moduletype_count=count_related(ModuleType, 'manufacturer'), + inventoryitem_count=count_related(InventoryItem, 'manufacturer'), + platform_count=count_related(Platform, 'manufacturer') ) table = tables.ManufacturerTable