Skip to content

Commit

Permalink
adds module status to module bay table #11652
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi1693 committed May 3, 2023
1 parent 01fa6e2 commit c4a64ce
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
'VirtualDeviceContextTable'
)

MODULEBAY_STATUS = """
{% badge record.installed_module.get_status_display bg_color=record.installed_module.get_status_color %}
"""


def get_cabletermination_row_class(record):
if record.mark_connected:
Expand Down Expand Up @@ -781,28 +785,35 @@ class ModuleBayTable(DeviceComponentTable):
tags = columns.TagColumn(
url_name='dcim:modulebay_list'
)
status = columns.TemplateColumn(
template_code=MODULEBAY_STATUS
)

class Meta(DeviceComponentTable.Meta):
model = models.ModuleBay
fields = (
'pk', 'id', 'name', 'device', 'label', 'position', 'installed_module', 'module_serial', 'module_asset_tag',
'description', 'tags',
'pk', 'id', 'name', 'device', 'label', 'position', 'installed_module', 'status', 'module_serial',
'module_asset_tag', 'description', 'tags',
)
default_columns = ('pk', 'name', 'device', 'label', 'installed_module', 'description')
default_columns = ('pk', 'name', 'device', 'label', 'installed_module', 'status', 'description')


class DeviceModuleBayTable(ModuleBayTable):
actions = columns.ActionsColumn(
extra_buttons=MODULEBAY_BUTTONS
)

status = columns.TemplateColumn(
template_code=MODULEBAY_STATUS,
)

class Meta(DeviceComponentTable.Meta):
model = models.ModuleBay
fields = (
'pk', 'id', 'name', 'label', 'position', 'installed_module', 'module_serial', 'module_asset_tag',
'pk', 'id', 'name', 'label', 'position', 'installed_module', 'status', 'module_serial', 'module_asset_tag',
'description', 'tags', 'actions',
)
default_columns = ('pk', 'name', 'label', 'installed_module', 'description')
default_columns = ('pk', 'name', 'label', 'installed_module', 'status', 'description')


class InventoryItemTable(DeviceComponentTable):
Expand Down

0 comments on commit c4a64ce

Please sign in to comment.