From a6ff6505c60695ae0398dd96a282c32f58b3402b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 May 2019 15:20:36 -0400 Subject: [PATCH] Closes #3151: Add inventory item count to manufacturers list --- CHANGELOG.md | 1 + netbox/dcim/tables.py | 24 +++++++++++++++++------- netbox/dcim/views.py | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f22f4031c..ba433b3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * [#2813](https://github.com/digitalocean/netbox/issues/2813) - Add tenant group filters * [#3085](https://github.com/digitalocean/netbox/issues/3085) - Catch all exceptions during export template rendering * [#3138](https://github.com/digitalocean/netbox/issues/3138) - Add 2.5GE and 5GE interface form factors +* [#3151](https://github.com/digitalocean/netbox/issues/3151) - Add inventory item count to manufacturers list * [#3156](https://github.com/digitalocean/netbox/issues/3156) - Add site link to rack reservations overview * [#3183](https://github.com/digitalocean/netbox/issues/3183) - Enable bulk deletion of sites * [#3185](https://github.com/digitalocean/netbox/issues/3185) - Improve performance for custom field access within templates diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index 20c1154f5..aec96d04f 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -328,16 +328,26 @@ class RackReservationTable(BaseTable): class ManufacturerTable(BaseTable): pk = ToggleColumn() - name = tables.LinkColumn(verbose_name='Name') - devicetype_count = tables.Column(verbose_name='Device Types') - platform_count = tables.Column(verbose_name='Platforms') - slug = tables.Column(verbose_name='Slug') - actions = tables.TemplateColumn(template_code=MANUFACTURER_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, - verbose_name='') + name = tables.LinkColumn() + devicetype_count = tables.Column( + verbose_name='Device Types' + ) + inventoryitem_count = tables.Column( + verbose_name='Inventory Items' + ) + platform_count = tables.Column( + verbose_name='Platforms' + ) + slug = tables.Column() + actions = tables.TemplateColumn( + template_code=MANUFACTURER_ACTIONS, + attrs={'td': {'class': 'text-right noprint'}}, + verbose_name='' + ) class Meta(BaseTable.Meta): model = Manufacturer - fields = ('pk', 'name', 'devicetype_count', 'platform_count', 'slug', 'actions') + fields = ('pk', 'name', 'devicetype_count', 'inventoryitem_count', 'platform_count', 'slug', 'actions') # diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 964f1473c..3cbb2a508 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -516,6 +516,7 @@ class RackReservationBulkDeleteView(PermissionRequiredMixin, BulkDeleteView): class ManufacturerListView(ObjectListView): queryset = Manufacturer.objects.annotate( devicetype_count=Count('device_types', distinct=True), + inventoryitem_count=Count('inventory_items', distinct=True), platform_count=Count('platforms', distinct=True), ) table = tables.ManufacturerTable