1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #8804: Include module type count on manufacturer view

This commit is contained in:
jeremystretch
2022-03-07 13:44:27 -05:00
parent 07f2cdac58
commit 18c9ee2f9d
2 changed files with 12 additions and 2 deletions

View File

@ -735,21 +735,25 @@ class ManufacturerView(generic.ObjectView):
queryset = Manufacturer.objects.all()
def get_extra_context(self, request, instance):
devicetypes = DeviceType.objects.restrict(request.user, 'view').filter(
device_types = DeviceType.objects.restrict(request.user, 'view').filter(
manufacturer=instance
).annotate(
instance_count=count_related(Device, 'device_type')
)
module_types = ModuleType.objects.restrict(request.user, 'view').filter(
manufacturer=instance
)
inventory_items = InventoryItem.objects.restrict(request.user, 'view').filter(
manufacturer=instance
)
devicetypes_table = tables.DeviceTypeTable(devicetypes, exclude=('manufacturer',))
devicetypes_table = tables.DeviceTypeTable(device_types, exclude=('manufacturer',))
devicetypes_table.configure(request)
return {
'devicetypes_table': devicetypes_table,
'inventory_item_count': inventory_items.count(),
'module_type_count': module_types.count(),
}

View File

@ -34,6 +34,12 @@
<a href="{% url 'dcim:devicetype_list' %}?manufacturer_id={{ object.pk }}">{{ devicetypes_table.rows|length }}</a>
</td>
</tr>
<tr>
<th scope="row">Module types</th>
<td>
<a href="{% url 'dcim:moduletype_list' %}?manufacturer_id={{ object.pk }}">{{ module_type_count }}</a>
</td>
</tr>
<tr>
<th scope="row">Inventory Items</th>
<td>