mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 09:28:38 -06:00
Adds inventory item children view (#14217)
* adds inventory item children view #14112 * Use existing child_items relation --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
1203d761f4
commit
0603dd1be4
@ -2993,6 +2993,25 @@ class InventoryItemBulkDeleteView(generic.BulkDeleteView):
|
|||||||
template_name = 'dcim/inventoryitem_bulk_delete.html'
|
template_name = 'dcim/inventoryitem_bulk_delete.html'
|
||||||
|
|
||||||
|
|
||||||
|
@register_model_view(InventoryItem, 'children')
|
||||||
|
class InventoryItemChildrenView(generic.ObjectChildrenView):
|
||||||
|
queryset = InventoryItem.objects.all()
|
||||||
|
child_model = InventoryItem
|
||||||
|
table = tables.InventoryItemTable
|
||||||
|
filterset = filtersets.InventoryItemFilterSet
|
||||||
|
template_name = 'generic/object_children.html'
|
||||||
|
tab = ViewTab(
|
||||||
|
label=_('Children'),
|
||||||
|
badge=lambda obj: obj.child_items.count(),
|
||||||
|
permission='dcim.view_inventoryitem',
|
||||||
|
hide_if_empty=True,
|
||||||
|
weight=5000
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_children(self, request, parent):
|
||||||
|
return parent.child_items.restrict(request.user, 'view')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Inventory item roles
|
# Inventory item roles
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user