From 047d717532d12c2d3c842aea2edc62a1cb69bc9a Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 31 Jul 2024 14:04:51 -0400 Subject: [PATCH] Add missing table columns --- netbox/dcim/tables/racks.py | 32 +++++++++++++++++++++++--------- netbox/dcim/views.py | 4 +++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py index 064a5a43d..b8295c286 100644 --- a/netbox/dcim/tables/racks.py +++ b/netbox/dcim/tables/racks.py @@ -84,6 +84,11 @@ class RackTypeTable(NetBoxTable): comments = columns.MarkdownColumn( verbose_name=_('Comments'), ) + instance_count = columns.LinkedCountColumn( + viewname='dcim:rack_list', + url_params={'rack_type_id': 'pk'}, + verbose_name=_('Instances') + ) tags = columns.TagColumn( url_name='dcim:rack_list' ) @@ -92,11 +97,11 @@ class RackTypeTable(NetBoxTable): model = RackType fields = ( 'pk', 'id', 'name', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', - 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments', 'tags', - 'created', 'last_updated', + 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments', + 'instance_count', 'tags', 'created', 'last_updated', ) default_columns = ( - 'pk', 'name', 'manufacturer', 'type', 'u_height', 'description', + 'pk', 'name', 'manufacturer', 'type', 'u_height', 'description', 'instance_count', ) @@ -124,6 +129,15 @@ class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable): role = columns.ColoredLabelColumn( verbose_name=_('Role'), ) + manufacturer = tables.Column( + verbose_name=_('Manufacturer'), + accessor=Accessor('rack_type__manufacturer'), + linkify=True + ) + rack_type = tables.Column( + linkify=True, + verbose_name=_('Type') + ) u_height = tables.TemplateColumn( template_code="{{ value }}U", verbose_name=_('Height') @@ -169,14 +183,14 @@ class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable): class Meta(NetBoxTable.Meta): model = Rack fields = ( - 'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', 'serial', - 'asset_tag', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', 'outer_depth', - 'mounting_depth', 'airflow', 'weight', 'max_weight', 'comments', 'device_count', 'get_utilization', - 'get_power_utilization', 'description', 'contacts', 'tags', 'created', 'last_updated', + 'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', + 'rack_type', 'serial', 'asset_tag', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', + 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'comments', 'device_count', + 'get_utilization', 'get_power_utilization', 'description', 'contacts', 'tags', 'created', 'last_updated', ) default_columns = ( - 'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count', - 'get_utilization', + 'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'rack_type', 'u_height', + 'device_count', 'get_utilization', ) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 5ff20f35e..5ad619452 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -584,7 +584,9 @@ class RackRoleBulkDeleteView(generic.BulkDeleteView): # class RackTypeListView(generic.ObjectListView): - queryset = RackType.objects.all() + queryset = RackType.objects.annotate( + instance_count=count_related(Rack, 'rack_type') + ) filterset = filtersets.RackTypeFilterSet filterset_form = forms.RackTypeFilterForm table = tables.RackTypeTable