Skip to content

Commit

Permalink
Fixes netbox-community#6771: Add count of inventory items to manufact…
Browse files Browse the repository at this point in the history
…urer view
  • Loading branch information
jeremystretch authored and candlerb committed Aug 4, 2021
1 parent 13acbf6 commit 0a1d72c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/version-2.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

### Other Changes

* [#6771](https://github.com/netbox-community/netbox/issues/6771) - Add count of inventory items to manufacturer view
* [#6781](https://github.com/netbox-community/netbox/issues/6781) - Database query caching is now disabled by default

---
Expand Down
4 changes: 4 additions & 0 deletions netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,17 @@ def get_extra_context(self, request, instance):
).annotate(
instance_count=count_related(Device, 'device_type')
)
inventory_items = InventoryItem.objects.restrict(request.user, 'view').filter(
manufacturer=instance
)

devicetypes_table = tables.DeviceTypeTable(devicetypes)
devicetypes_table.columns.hide('manufacturer')
paginate_table(devicetypes_table, request)

return {
'devicetypes_table': devicetypes_table,
'inventory_item_count': inventory_items.count(),
}


Expand Down
6 changes: 6 additions & 0 deletions netbox/templates/dcim/manufacturer.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<a href="{% url 'dcim:devicetype_list' %}?manufacturer_id={{ object.pk }}">{{ devicetypes_table.rows|length }}</a>
</td>
</tr>
<tr>
<td>Inventory Items</td>
<td>
<a href="{% url 'dcim:inventoryitem_list' %}?manufacturer_id={{ object.pk }}">{{ inventory_item_count }}</a>
</td>
</tr>
</table>
</div>
{% plugin_left_page object %}
Expand Down

0 comments on commit 0a1d72c

Please sign in to comment.