mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-21 12:08:38 -06:00
Add 'add' action for inventory items panel
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.ui import attrs, panels
|
||||
from netbox.ui import actions, attrs, panels
|
||||
|
||||
|
||||
class SitePanel(panels.ObjectAttributesPanel):
|
||||
@@ -400,6 +401,15 @@ class InventoryItemsPanel(panels.ObjectPanel):
|
||||
"""
|
||||
template_name = 'dcim/panels/component_inventory_items.html'
|
||||
title = _('Inventory Items')
|
||||
actions = [
|
||||
actions.AddObject(
|
||||
'dcim.inventoryitem',
|
||||
url_params={
|
||||
'component_type': lambda ctx: ContentType.objects.get_for_model(ctx['object']).pk,
|
||||
'component_id': lambda ctx: ctx['object'].pk,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
def render(self, context):
|
||||
ctx = self.get_context(context)
|
||||
|
||||
Reference in New Issue
Block a user