Просмотр исходного кода

Closes #3151: Add inventory item count to manufacturers list

Jeremy Stretch 6 лет назад
Родитель
Сommit
a6ff6505c6
3 измененных файлов с 19 добавлено и 7 удалено
  1. 1 0
      CHANGELOG.md
  2. 17 7
      netbox/dcim/tables.py
  3. 1 0
      netbox/dcim/views.py

+ 1 - 0
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

+ 17 - 7
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')
 
 
 #

+ 1 - 0
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