Add missing table columns

This commit is contained in:
Jeremy Stretch 2024-07-31 14:04:51 -04:00
parent 52692d49b6
commit 047d717532
2 changed files with 26 additions and 10 deletions

View File

@ -84,6 +84,11 @@ class RackTypeTable(NetBoxTable):
comments = columns.MarkdownColumn( comments = columns.MarkdownColumn(
verbose_name=_('Comments'), verbose_name=_('Comments'),
) )
instance_count = columns.LinkedCountColumn(
viewname='dcim:rack_list',
url_params={'rack_type_id': 'pk'},
verbose_name=_('Instances')
)
tags = columns.TagColumn( tags = columns.TagColumn(
url_name='dcim:rack_list' url_name='dcim:rack_list'
) )
@ -92,11 +97,11 @@ class RackTypeTable(NetBoxTable):
model = RackType model = RackType
fields = ( fields = (
'pk', 'id', 'name', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', 'pk', 'id', 'name', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width',
'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments', 'tags', 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments',
'created', 'last_updated', 'instance_count', 'tags', 'created', 'last_updated',
) )
default_columns = ( 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( role = columns.ColoredLabelColumn(
verbose_name=_('Role'), 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( u_height = tables.TemplateColumn(
template_code="{{ value }}U", template_code="{{ value }}U",
verbose_name=_('Height') verbose_name=_('Height')
@ -169,14 +183,14 @@ class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
class Meta(NetBoxTable.Meta): class Meta(NetBoxTable.Meta):
model = Rack model = Rack
fields = ( fields = (
'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', 'serial', 'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role',
'asset_tag', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', 'outer_depth', 'rack_type', 'serial', 'asset_tag', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width',
'mounting_depth', 'airflow', 'weight', 'max_weight', 'comments', 'device_count', 'get_utilization', 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'comments', 'device_count',
'get_power_utilization', 'description', 'contacts', 'tags', 'created', 'last_updated', 'get_utilization', 'get_power_utilization', 'description', 'contacts', 'tags', 'created', 'last_updated',
) )
default_columns = ( default_columns = (
'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count', 'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'rack_type', 'u_height',
'get_utilization', 'device_count', 'get_utilization',
) )

View File

@ -584,7 +584,9 @@ class RackRoleBulkDeleteView(generic.BulkDeleteView):
# #
class RackTypeListView(generic.ObjectListView): class RackTypeListView(generic.ObjectListView):
queryset = RackType.objects.all() queryset = RackType.objects.annotate(
instance_count=count_related(Rack, 'rack_type')
)
filterset = filtersets.RackTypeFilterSet filterset = filtersets.RackTypeFilterSet
filterset_form = forms.RackTypeFilterForm filterset_form = forms.RackTypeFilterForm
table = tables.RackTypeTable table = tables.RackTypeTable