mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-12 10:38:16 -06:00
Move duplicated dicts into inheritable meta class
This commit is contained in:
parent
668d1738f3
commit
0a76d962ce
@ -43,12 +43,14 @@ MODULEBAY_STATUS = """
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def get_cabletermination_row_class(record):
|
class ConnectionDeviceComponentTableMixin:
|
||||||
if record.mark_connected:
|
class Meta:
|
||||||
return 'success'
|
row_attrs = {
|
||||||
elif record.cable:
|
'data-name': lambda record: record.name,
|
||||||
return record.cable.get_status_color()
|
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
||||||
return ''
|
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
||||||
|
'data-type': lambda record: record.type
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -382,19 +384,13 @@ class DeviceConsolePortTable(ConsolePortTable):
|
|||||||
extra_buttons=CONSOLEPORT_BUTTONS
|
extra_buttons=CONSOLEPORT_BUTTONS
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(ConnectionDeviceComponentTableMixin.Meta, DeviceComponentTable.Meta):
|
||||||
model = models.ConsolePort
|
model = models.ConsolePort
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
|
||||||
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions'
|
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions'
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
|
||||||
row_attrs = {
|
|
||||||
'data-name': lambda record: record.name,
|
|
||||||
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
|
||||||
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
|
||||||
'data-type': lambda record: record.type
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
class ConsoleServerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||||
@ -430,19 +426,13 @@ class DeviceConsoleServerPortTable(ConsoleServerPortTable):
|
|||||||
extra_buttons=CONSOLESERVERPORT_BUTTONS
|
extra_buttons=CONSOLESERVERPORT_BUTTONS
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(ConnectionDeviceComponentTableMixin.Meta, DeviceComponentTable.Meta):
|
||||||
model = models.ConsoleServerPort
|
model = models.ConsoleServerPort
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
|
||||||
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
|
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
|
||||||
row_attrs = {
|
|
||||||
'data-name': lambda record: record.name,
|
|
||||||
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
|
||||||
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
|
||||||
'data-type': lambda record: record.type
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||||
@ -485,7 +475,7 @@ class DevicePowerPortTable(PowerPortTable):
|
|||||||
extra_buttons=POWERPORT_BUTTONS
|
extra_buttons=POWERPORT_BUTTONS
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(ConnectionDeviceComponentTableMixin.Meta, DeviceComponentTable.Meta):
|
||||||
model = models.PowerPort
|
model = models.PowerPort
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'maximum_draw', 'allocated_draw',
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'maximum_draw', 'allocated_draw',
|
||||||
@ -494,12 +484,6 @@ class DevicePowerPortTable(PowerPortTable):
|
|||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'cable', 'connection',
|
'pk', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'cable', 'connection',
|
||||||
)
|
)
|
||||||
row_attrs = {
|
|
||||||
'data-name': lambda record: record.name,
|
|
||||||
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
|
||||||
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
|
||||||
'data-type': lambda record: record.type
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletTable(ModularDeviceComponentTable, PathEndpointTable):
|
class PowerOutletTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||||
@ -539,7 +523,7 @@ class DevicePowerOutletTable(PowerOutletTable):
|
|||||||
extra_buttons=POWEROUTLET_BUTTONS
|
extra_buttons=POWEROUTLET_BUTTONS
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(ConnectionDeviceComponentTableMixin.Meta, DeviceComponentTable.Meta):
|
||||||
model = models.PowerOutlet
|
model = models.PowerOutlet
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'power_port', 'feed_leg', 'description',
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'power_port', 'feed_leg', 'description',
|
||||||
@ -548,12 +532,6 @@ class DevicePowerOutletTable(PowerOutletTable):
|
|||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection',
|
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection',
|
||||||
)
|
)
|
||||||
row_attrs = {
|
|
||||||
'data-name': lambda record: record.name,
|
|
||||||
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
|
||||||
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
|
||||||
'data-type': lambda record: record.type
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class BaseInterfaceTable(NetBoxTable):
|
class BaseInterfaceTable(NetBoxTable):
|
||||||
@ -745,7 +723,7 @@ class DeviceFrontPortTable(FrontPortTable):
|
|||||||
extra_buttons=FRONTPORT_BUTTONS
|
extra_buttons=FRONTPORT_BUTTONS
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(ConnectionDeviceComponentTableMixin.Meta, DeviceComponentTable.Meta):
|
||||||
model = models.FrontPort
|
model = models.FrontPort
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'rear_port', 'rear_port_position',
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'rear_port', 'rear_port_position',
|
||||||
@ -754,12 +732,6 @@ class DeviceFrontPortTable(FrontPortTable):
|
|||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable', 'link_peer',
|
'pk', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable', 'link_peer',
|
||||||
)
|
)
|
||||||
row_attrs = {
|
|
||||||
'data-name': lambda record: record.name,
|
|
||||||
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
|
||||||
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
|
||||||
'data-type': lambda record: record.type
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class RearPortTable(ModularDeviceComponentTable, CableTerminationTable):
|
class RearPortTable(ModularDeviceComponentTable, CableTerminationTable):
|
||||||
@ -798,7 +770,7 @@ class DeviceRearPortTable(RearPortTable):
|
|||||||
extra_buttons=REARPORT_BUTTONS
|
extra_buttons=REARPORT_BUTTONS
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(ConnectionDeviceComponentTableMixin.Meta, DeviceComponentTable.Meta):
|
||||||
model = models.RearPort
|
model = models.RearPort
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'positions', 'description', 'mark_connected',
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'positions', 'description', 'mark_connected',
|
||||||
@ -807,12 +779,6 @@ class DeviceRearPortTable(RearPortTable):
|
|||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'link_peer',
|
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'link_peer',
|
||||||
)
|
)
|
||||||
row_attrs = {
|
|
||||||
'data-name': lambda record: record.name,
|
|
||||||
'data-mark-connected': lambda record: "true" if record.mark_connected else "false",
|
|
||||||
'data-cable-status': lambda record: record.cable.status if record.cable else "",
|
|
||||||
'data-type': lambda record: record.type
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceBayTable(DeviceComponentTable):
|
class DeviceBayTable(DeviceComponentTable):
|
||||||
|
Loading…
Reference in New Issue
Block a user