diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index ce79088d0..f9498c4a8 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -1032,7 +1032,7 @@ class RearPortTemplateForm(ModularComponentTemplateForm): ] -class ModuleBayTemplateForm(ComponentTemplateForm): +class ModuleBayTemplateForm(ModularComponentTemplateForm): fieldsets = ( FieldSet('device_type', 'module_type', 'name', 'label', 'position', 'description'), ) @@ -1452,7 +1452,7 @@ class RearPortForm(ModularDeviceComponentForm): ] -class ModuleBayForm(DeviceComponentForm): +class ModuleBayForm(ModularDeviceComponentForm): fieldsets = ( FieldSet('device', 'module', 'name', 'label', 'position', 'description', 'tags',), ) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 29c39daec..d00e25d8f 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -852,6 +852,11 @@ class ModuleBayTable(ModularDeviceComponentTable): 'args': [Accessor('device_id')], } ) + parent_bay = tables.Column( + accessor=tables.A('module__module_bay'), + linkify=True, + verbose_name=_('Parent Bay') + ) installed_module = tables.Column( linkify=True, verbose_name=_('Installed Module') @@ -876,10 +881,18 @@ class ModuleBayTable(ModularDeviceComponentTable): class Meta(DeviceComponentTable.Meta): model = models.ModuleBay fields = ( - 'pk', 'id', 'name', 'device', 'label', 'position', 'installed_module', 'module_status', 'module_serial', - 'module_asset_tag', 'description', 'tags', + 'pk', 'id', 'name', 'device', 'parent_bay', 'label', 'position', 'installed_module', 'module_status', + 'module_serial', 'module_asset_tag', 'description', 'tags', ) - default_columns = ('pk', 'name', 'device', 'label', 'installed_module', 'module_status', 'description') + default_columns = ( + 'pk', 'name', 'device', 'parent_bay', 'label', 'installed_module', 'module_status', 'description', + ) + + def render_parent_bay(self, value): + return value.name if value else '' + + def render_installed_module(self, value): + return value.module_type if value else '' class DeviceModuleBayTable(ModuleBayTable): @@ -890,10 +903,10 @@ class DeviceModuleBayTable(ModuleBayTable): class Meta(DeviceComponentTable.Meta): model = models.ModuleBay fields = ( - 'pk', 'id', 'name', 'label', 'position', 'installed_module', 'module_status', 'module_serial', 'module_asset_tag', - 'description', 'tags', 'actions', + 'pk', 'id', 'parent_bay', 'name', 'label', 'position', 'installed_module', 'module_status', 'module_serial', + 'module_asset_tag', 'description', 'tags', 'actions', ) - default_columns = ('pk', 'name', 'label', 'installed_module', 'module_status', 'description') + default_columns = ('pk', 'parent_bay', 'name', 'label', 'installed_module', 'module_status', 'description') class InventoryItemTable(DeviceComponentTable): diff --git a/netbox/templates/dcim/module.html b/netbox/templates/dcim/module.html index 2180a83a3..dcd08bd4e 100644 --- a/netbox/templates/dcim/module.html +++ b/netbox/templates/dcim/module.html @@ -39,6 +39,9 @@ {% if perms.dcim.add_rearport %}