mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #8469: Move BaseTable, columns to netbox core app
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import django_tables2 as tables
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from utilities.tables import BaseTable, BooleanColumn
|
||||
from dcim.models import ConsolePort, Interface, PowerPort
|
||||
from netbox.tables import BaseTable, columns
|
||||
from .cables import *
|
||||
from .devices import *
|
||||
from .devicetypes import *
|
||||
@@ -36,7 +36,7 @@ class ConsoleConnectionTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Console Port'
|
||||
)
|
||||
reachable = BooleanColumn(
|
||||
reachable = columns.BooleanColumn(
|
||||
accessor=Accessor('_path__is_active'),
|
||||
verbose_name='Reachable'
|
||||
)
|
||||
@@ -67,7 +67,7 @@ class PowerConnectionTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Power Port'
|
||||
)
|
||||
reachable = BooleanColumn(
|
||||
reachable = columns.BooleanColumn(
|
||||
accessor=Accessor('_path__is_active'),
|
||||
verbose_name='Reachable'
|
||||
)
|
||||
@@ -101,7 +101,7 @@ class InterfaceConnectionTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Interface B'
|
||||
)
|
||||
reachable = BooleanColumn(
|
||||
reachable = columns.BooleanColumn(
|
||||
accessor=Accessor('_path__is_active'),
|
||||
verbose_name='Reachable'
|
||||
)
|
||||
|
@@ -2,8 +2,8 @@ import django_tables2 as tables
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from dcim.models import Cable
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import BaseTable, ChoiceFieldColumn, ColorColumn, TagColumn, TemplateColumn, ToggleColumn
|
||||
from .template_code import CABLE_LENGTH, CABLE_TERMINATION_PARENT
|
||||
|
||||
__all__ = (
|
||||
@@ -16,7 +16,7 @@ __all__ = (
|
||||
#
|
||||
|
||||
class CableTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
termination_a_parent = tables.TemplateColumn(
|
||||
template_code=CABLE_TERMINATION_PARENT,
|
||||
accessor=Accessor('termination_a'),
|
||||
@@ -41,14 +41,14 @@ class CableTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Termination B'
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
length = TemplateColumn(
|
||||
length = columns.TemplateColumn(
|
||||
template_code=CABLE_LENGTH,
|
||||
order_by='_abs_length'
|
||||
)
|
||||
color = ColorColumn()
|
||||
tags = TagColumn(
|
||||
color = columns.ColorColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:cable_list'
|
||||
)
|
||||
|
||||
|
@@ -5,11 +5,8 @@ from dcim.models import (
|
||||
ConsolePort, ConsoleServerPort, Device, DeviceBay, DeviceRole, FrontPort, Interface, InventoryItem,
|
||||
InventoryItemRole, ModuleBay, Platform, PowerOutlet, PowerPort, RearPort, VirtualChassis,
|
||||
)
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, BooleanColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn,
|
||||
MarkdownColumn, TagColumn, TemplateColumn, ToggleColumn,
|
||||
)
|
||||
from .template_code import *
|
||||
|
||||
__all__ = (
|
||||
@@ -75,23 +72,23 @@ def get_interface_state_attribute(record):
|
||||
#
|
||||
|
||||
class DeviceRoleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
device_count = LinkedCountColumn(
|
||||
device_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'role_id': 'pk'},
|
||||
verbose_name='Devices'
|
||||
)
|
||||
vm_count = LinkedCountColumn(
|
||||
vm_count = columns.LinkedCountColumn(
|
||||
viewname='virtualization:virtualmachine_list',
|
||||
url_params={'role_id': 'pk'},
|
||||
verbose_name='VMs'
|
||||
)
|
||||
color = ColorColumn()
|
||||
vm_role = BooleanColumn()
|
||||
tags = TagColumn(
|
||||
color = columns.ColorColumn()
|
||||
vm_role = columns.BooleanColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:devicerole_list'
|
||||
)
|
||||
|
||||
@@ -109,21 +106,21 @@ class DeviceRoleTable(BaseTable):
|
||||
#
|
||||
|
||||
class PlatformTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
device_count = LinkedCountColumn(
|
||||
device_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'platform_id': 'pk'},
|
||||
verbose_name='Devices'
|
||||
)
|
||||
vm_count = LinkedCountColumn(
|
||||
vm_count = columns.LinkedCountColumn(
|
||||
viewname='virtualization:virtualmachine_list',
|
||||
url_params={'platform_id': 'pk'},
|
||||
verbose_name='VMs'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:platform_list'
|
||||
)
|
||||
|
||||
@@ -143,12 +140,12 @@ class PlatformTable(BaseTable):
|
||||
#
|
||||
|
||||
class DeviceTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.TemplateColumn(
|
||||
order_by=('_name',),
|
||||
template_code=DEVICE_LINK
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
@@ -159,7 +156,7 @@ class DeviceTable(BaseTable):
|
||||
rack = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
device_role = ColoredLabelColumn(
|
||||
device_role = columns.ColoredLabelColumn(
|
||||
verbose_name='Role'
|
||||
)
|
||||
manufacturer = tables.Column(
|
||||
@@ -195,8 +192,8 @@ class DeviceTable(BaseTable):
|
||||
vc_priority = tables.Column(
|
||||
verbose_name='VC Priority'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:device_list'
|
||||
)
|
||||
|
||||
@@ -218,7 +215,7 @@ class DeviceImportTable(BaseTable):
|
||||
name = tables.TemplateColumn(
|
||||
template_code=DEVICE_LINK
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
@@ -244,7 +241,7 @@ class DeviceImportTable(BaseTable):
|
||||
#
|
||||
|
||||
class DeviceComponentTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -274,22 +271,22 @@ class CableTerminationTable(BaseTable):
|
||||
cable = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
cable_color = ColorColumn(
|
||||
cable_color = columns.ColorColumn(
|
||||
accessor='cable.color',
|
||||
orderable=False,
|
||||
verbose_name='Cable Color'
|
||||
)
|
||||
link_peer = TemplateColumn(
|
||||
link_peer = columns.TemplateColumn(
|
||||
accessor='_link_peer',
|
||||
template_code=LINKTERMINATION,
|
||||
orderable=False,
|
||||
verbose_name='Link Peer'
|
||||
)
|
||||
mark_connected = BooleanColumn()
|
||||
mark_connected = columns.BooleanColumn()
|
||||
|
||||
|
||||
class PathEndpointTable(CableTerminationTable):
|
||||
connection = TemplateColumn(
|
||||
connection = columns.TemplateColumn(
|
||||
accessor='_path.last_node',
|
||||
template_code=LINKTERMINATION,
|
||||
verbose_name='Connection',
|
||||
@@ -304,7 +301,7 @@ class ConsolePortTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||
'args': [Accessor('device_id')],
|
||||
}
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:consoleport_list'
|
||||
)
|
||||
|
||||
@@ -323,7 +320,7 @@ class DeviceConsolePortTable(ConsolePortTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=CONSOLEPORT_BUTTONS
|
||||
)
|
||||
|
||||
@@ -346,7 +343,7 @@ class ConsoleServerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||
'args': [Accessor('device_id')],
|
||||
}
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:consoleserverport_list'
|
||||
)
|
||||
|
||||
@@ -366,7 +363,7 @@ class DeviceConsoleServerPortTable(ConsoleServerPortTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=CONSOLESERVERPORT_BUTTONS
|
||||
)
|
||||
|
||||
@@ -389,7 +386,7 @@ class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||
'args': [Accessor('device_id')],
|
||||
}
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:powerport_list'
|
||||
)
|
||||
|
||||
@@ -410,7 +407,7 @@ class DevicePowerPortTable(PowerPortTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=POWERPORT_BUTTONS
|
||||
)
|
||||
|
||||
@@ -438,7 +435,7 @@ class PowerOutletTable(ModularDeviceComponentTable, PathEndpointTable):
|
||||
power_port = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:poweroutlet_list'
|
||||
)
|
||||
|
||||
@@ -458,7 +455,7 @@ class DevicePowerOutletTable(PowerOutletTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=POWEROUTLET_BUTTONS
|
||||
)
|
||||
|
||||
@@ -477,7 +474,7 @@ class DevicePowerOutletTable(PowerOutletTable):
|
||||
|
||||
|
||||
class BaseInterfaceTable(BaseTable):
|
||||
enabled = BooleanColumn()
|
||||
enabled = columns.BooleanColumn()
|
||||
ip_addresses = tables.TemplateColumn(
|
||||
template_code=INTERFACE_IPADDRESSES,
|
||||
orderable=False,
|
||||
@@ -490,7 +487,7 @@ class BaseInterfaceTable(BaseTable):
|
||||
verbose_name='FHRP Groups'
|
||||
)
|
||||
untagged_vlan = tables.Column(linkify=True)
|
||||
tagged_vlans = TemplateColumn(
|
||||
tagged_vlans = columns.TemplateColumn(
|
||||
template_code=INTERFACE_TAGGED_VLANS,
|
||||
orderable=False,
|
||||
verbose_name='Tagged VLANs'
|
||||
@@ -504,11 +501,11 @@ class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpoi
|
||||
'args': [Accessor('device_id')],
|
||||
}
|
||||
)
|
||||
mgmt_only = BooleanColumn()
|
||||
mgmt_only = columns.BooleanColumn()
|
||||
wireless_link = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
wireless_lans = TemplateColumn(
|
||||
wireless_lans = columns.TemplateColumn(
|
||||
template_code=INTERFACE_WIRELESS_LANS,
|
||||
orderable=False,
|
||||
verbose_name='Wireless LANs'
|
||||
@@ -516,7 +513,7 @@ class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpoi
|
||||
vrf = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:interface_list'
|
||||
)
|
||||
|
||||
@@ -550,7 +547,7 @@ class DeviceInterfaceTable(InterfaceTable):
|
||||
linkify=True,
|
||||
verbose_name='LAG'
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=INTERFACE_BUTTONS
|
||||
)
|
||||
|
||||
@@ -582,14 +579,14 @@ class FrontPortTable(ModularDeviceComponentTable, CableTerminationTable):
|
||||
'args': [Accessor('device_id')],
|
||||
}
|
||||
)
|
||||
color = ColorColumn()
|
||||
color = columns.ColorColumn()
|
||||
rear_port_position = tables.Column(
|
||||
verbose_name='Position'
|
||||
)
|
||||
rear_port = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:frontport_list'
|
||||
)
|
||||
|
||||
@@ -612,7 +609,7 @@ class DeviceFrontPortTable(FrontPortTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=FRONTPORT_BUTTONS
|
||||
)
|
||||
|
||||
@@ -637,8 +634,8 @@ class RearPortTable(ModularDeviceComponentTable, CableTerminationTable):
|
||||
'args': [Accessor('device_id')],
|
||||
}
|
||||
)
|
||||
color = ColorColumn()
|
||||
tags = TagColumn(
|
||||
color = columns.ColorColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:rearport_list'
|
||||
)
|
||||
|
||||
@@ -658,7 +655,7 @@ class DeviceRearPortTable(RearPortTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=REARPORT_BUTTONS
|
||||
)
|
||||
|
||||
@@ -690,7 +687,7 @@ class DeviceBayTable(DeviceComponentTable):
|
||||
installed_device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:devicebay_list'
|
||||
)
|
||||
|
||||
@@ -711,7 +708,7 @@ class DeviceDeviceBayTable(DeviceBayTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=DEVICEBAY_BUTTONS
|
||||
)
|
||||
|
||||
@@ -734,7 +731,7 @@ class ModuleBayTable(DeviceComponentTable):
|
||||
linkify=True,
|
||||
verbose_name='Installed module'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:modulebay_list'
|
||||
)
|
||||
|
||||
@@ -745,7 +742,7 @@ class ModuleBayTable(DeviceComponentTable):
|
||||
|
||||
|
||||
class DeviceModuleBayTable(ModuleBayTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=MODULEBAY_BUTTONS
|
||||
)
|
||||
|
||||
@@ -773,8 +770,8 @@ class InventoryItemTable(DeviceComponentTable):
|
||||
orderable=False,
|
||||
linkify=True
|
||||
)
|
||||
discovered = BooleanColumn()
|
||||
tags = TagColumn(
|
||||
discovered = columns.BooleanColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:inventoryitem_list'
|
||||
)
|
||||
cable = None # Override DeviceComponentTable
|
||||
@@ -797,7 +794,7 @@ class DeviceInventoryItemTable(InventoryItemTable):
|
||||
order_by=Accessor('_name'),
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
)
|
||||
actions = ActionsColumn()
|
||||
actions = columns.ActionsColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = InventoryItem
|
||||
@@ -811,17 +808,17 @@ class DeviceInventoryItemTable(InventoryItemTable):
|
||||
|
||||
|
||||
class InventoryItemRoleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
inventoryitem_count = LinkedCountColumn(
|
||||
inventoryitem_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:inventoryitem_list',
|
||||
url_params={'role_id': 'pk'},
|
||||
verbose_name='Items'
|
||||
)
|
||||
color = ColorColumn()
|
||||
tags = TagColumn(
|
||||
color = columns.ColorColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:inventoryitemrole_list'
|
||||
)
|
||||
|
||||
@@ -838,19 +835,19 @@ class InventoryItemRoleTable(BaseTable):
|
||||
#
|
||||
|
||||
class VirtualChassisTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
master = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
member_count = LinkedCountColumn(
|
||||
member_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'virtual_chassis_id': 'pk'},
|
||||
verbose_name='Members'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:virtualchassis_list'
|
||||
)
|
||||
|
||||
|
@@ -5,9 +5,7 @@ from dcim.models import (
|
||||
ConsolePortTemplate, ConsoleServerPortTemplate, DeviceBayTemplate, DeviceType, FrontPortTemplate, InterfaceTemplate,
|
||||
InventoryItemTemplate, Manufacturer, ModuleBayTemplate, PowerOutletTemplate, PowerPortTemplate, RearPortTemplate,
|
||||
)
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, BooleanColumn, ColorColumn, LinkedCountColumn, MarkdownColumn, TagColumn, ToggleColumn,
|
||||
)
|
||||
from netbox.tables import BaseTable, columns
|
||||
from .template_code import MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
|
||||
__all__ = (
|
||||
@@ -31,7 +29,7 @@ __all__ = (
|
||||
#
|
||||
|
||||
class ManufacturerTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -45,7 +43,7 @@ class ManufacturerTable(BaseTable):
|
||||
verbose_name='Platforms'
|
||||
)
|
||||
slug = tables.Column()
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:manufacturer_list'
|
||||
)
|
||||
|
||||
@@ -65,21 +63,21 @@ class ManufacturerTable(BaseTable):
|
||||
#
|
||||
|
||||
class DeviceTypeTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
model = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='Device Type'
|
||||
)
|
||||
is_full_depth = BooleanColumn(
|
||||
is_full_depth = columns.BooleanColumn(
|
||||
verbose_name='Full Depth'
|
||||
)
|
||||
instance_count = LinkedCountColumn(
|
||||
instance_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'device_type_id': 'pk'},
|
||||
verbose_name='Instances'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:devicetype_list'
|
||||
)
|
||||
|
||||
@@ -99,7 +97,7 @@ class DeviceTypeTable(BaseTable):
|
||||
#
|
||||
|
||||
class ComponentTemplateTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
id = tables.Column(
|
||||
verbose_name='ID'
|
||||
)
|
||||
@@ -112,7 +110,7 @@ class ComponentTemplateTable(BaseTable):
|
||||
|
||||
|
||||
class ConsolePortTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -124,7 +122,7 @@ class ConsolePortTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class ConsoleServerPortTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -136,7 +134,7 @@ class ConsoleServerPortTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class PowerPortTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -148,7 +146,7 @@ class PowerPortTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class PowerOutletTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -160,10 +158,10 @@ class PowerOutletTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class InterfaceTemplateTable(ComponentTemplateTable):
|
||||
mgmt_only = BooleanColumn(
|
||||
mgmt_only = columns.BooleanColumn(
|
||||
verbose_name='Management Only'
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -178,8 +176,8 @@ class FrontPortTemplateTable(ComponentTemplateTable):
|
||||
rear_port_position = tables.Column(
|
||||
verbose_name='Position'
|
||||
)
|
||||
color = ColorColumn()
|
||||
actions = ActionsColumn(
|
||||
color = columns.ColorColumn()
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -191,8 +189,8 @@ class FrontPortTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class RearPortTemplateTable(ComponentTemplateTable):
|
||||
color = ColorColumn()
|
||||
actions = ActionsColumn(
|
||||
color = columns.ColorColumn()
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=MODULAR_COMPONENT_TEMPLATE_BUTTONS
|
||||
)
|
||||
@@ -204,7 +202,7 @@ class RearPortTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class ModuleBayTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
|
||||
@@ -215,7 +213,7 @@ class ModuleBayTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class DeviceBayTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
|
||||
@@ -226,7 +224,7 @@ class DeviceBayTemplateTable(ComponentTemplateTable):
|
||||
|
||||
|
||||
class InventoryItemTemplateTable(ComponentTemplateTable):
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
role = tables.Column(
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from dcim.models import Module, ModuleType
|
||||
from utilities.tables import BaseTable, LinkedCountColumn, MarkdownColumn, TagColumn, ToggleColumn
|
||||
from netbox.tables import BaseTable, columns
|
||||
|
||||
__all__ = (
|
||||
'ModuleTable',
|
||||
@@ -10,18 +10,18 @@ __all__ = (
|
||||
|
||||
|
||||
class ModuleTypeTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
model = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='Module Type'
|
||||
)
|
||||
instance_count = LinkedCountColumn(
|
||||
instance_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:module_list',
|
||||
url_params={'module_type_id': 'pk'},
|
||||
verbose_name='Instances'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:moduletype_list'
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ class ModuleTypeTable(BaseTable):
|
||||
|
||||
|
||||
class ModuleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -46,8 +46,8 @@ class ModuleTable(BaseTable):
|
||||
module_type = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:module_list'
|
||||
)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from dcim.models import PowerFeed, PowerPanel
|
||||
from utilities.tables import BaseTable, ChoiceFieldColumn, LinkedCountColumn, MarkdownColumn, TagColumn, ToggleColumn
|
||||
from netbox.tables import BaseTable, columns
|
||||
from .devices import CableTerminationTable
|
||||
|
||||
__all__ = (
|
||||
@@ -15,19 +15,19 @@ __all__ = (
|
||||
#
|
||||
|
||||
class PowerPanelTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
powerfeed_count = LinkedCountColumn(
|
||||
powerfeed_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:powerfeed_list',
|
||||
url_params={'power_panel_id': 'pk'},
|
||||
verbose_name='Feeds'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:powerpanel_list'
|
||||
)
|
||||
|
||||
@@ -44,7 +44,7 @@ class PowerPanelTable(BaseTable):
|
||||
# We're not using PathEndpointTable for PowerFeed because power connections
|
||||
# cannot traverse pass-through ports.
|
||||
class PowerFeedTable(CableTerminationTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -54,16 +54,16 @@ class PowerFeedTable(CableTerminationTable):
|
||||
rack = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
type = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
type = columns.ChoiceFieldColumn()
|
||||
max_utilization = tables.TemplateColumn(
|
||||
template_code="{{ value }}%"
|
||||
)
|
||||
available_power = tables.Column(
|
||||
verbose_name='Available power (VA)'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:powerfeed_list'
|
||||
)
|
||||
|
||||
|
@@ -2,11 +2,8 @@ import django_tables2 as tables
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from dcim.models import Rack, RackReservation, RackRole
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import (
|
||||
BaseTable, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn, MarkdownColumn, TagColumn,
|
||||
ToggleColumn, UtilizationColumn,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
'RackTable',
|
||||
@@ -20,11 +17,11 @@ __all__ = (
|
||||
#
|
||||
|
||||
class RackRoleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(linkify=True)
|
||||
rack_count = tables.Column(verbose_name='Racks')
|
||||
color = ColorColumn()
|
||||
tags = TagColumn(
|
||||
color = columns.ColorColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:rackrole_list'
|
||||
)
|
||||
|
||||
@@ -42,7 +39,7 @@ class RackRoleTable(BaseTable):
|
||||
#
|
||||
|
||||
class RackTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
order_by=('_name',),
|
||||
linkify=True
|
||||
@@ -54,27 +51,27 @@ class RackTable(BaseTable):
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
status = ChoiceFieldColumn()
|
||||
role = ColoredLabelColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
role = columns.ColoredLabelColumn()
|
||||
u_height = tables.TemplateColumn(
|
||||
template_code="{{ record.u_height }}U",
|
||||
verbose_name='Height'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
device_count = LinkedCountColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
device_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'rack_id': 'pk'},
|
||||
verbose_name='Devices'
|
||||
)
|
||||
get_utilization = UtilizationColumn(
|
||||
get_utilization = columns.UtilizationColumn(
|
||||
orderable=False,
|
||||
verbose_name='Space'
|
||||
)
|
||||
get_power_utilization = UtilizationColumn(
|
||||
get_power_utilization = columns.UtilizationColumn(
|
||||
orderable=False,
|
||||
verbose_name='Power'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:rack_list'
|
||||
)
|
||||
outer_width = tables.TemplateColumn(
|
||||
@@ -104,7 +101,7 @@ class RackTable(BaseTable):
|
||||
#
|
||||
|
||||
class RackReservationTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
reservation = tables.Column(
|
||||
accessor='pk',
|
||||
linkify=True
|
||||
@@ -121,7 +118,7 @@ class RackReservationTable(BaseTable):
|
||||
orderable=False,
|
||||
verbose_name='Units'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:rackreservation_list'
|
||||
)
|
||||
|
||||
|
@@ -1,10 +1,8 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from dcim.models import Location, Region, Site, SiteGroup
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, ChoiceFieldColumn, LinkedCountColumn, MarkdownColumn, MPTTColumn, TagColumn, ToggleColumn,
|
||||
)
|
||||
from .template_code import LOCATION_BUTTONS
|
||||
|
||||
__all__ = (
|
||||
@@ -20,16 +18,16 @@ __all__ = (
|
||||
#
|
||||
|
||||
class RegionTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = MPTTColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
name = columns.MPTTColumn(
|
||||
linkify=True
|
||||
)
|
||||
site_count = LinkedCountColumn(
|
||||
site_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:site_list',
|
||||
url_params={'region_id': 'pk'},
|
||||
verbose_name='Sites'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:region_list'
|
||||
)
|
||||
|
||||
@@ -46,16 +44,16 @@ class RegionTable(BaseTable):
|
||||
#
|
||||
|
||||
class SiteGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = MPTTColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
name = columns.MPTTColumn(
|
||||
linkify=True
|
||||
)
|
||||
site_count = LinkedCountColumn(
|
||||
site_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:site_list',
|
||||
url_params={'group_id': 'pk'},
|
||||
verbose_name='Sites'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:sitegroup_list'
|
||||
)
|
||||
|
||||
@@ -72,26 +70,26 @@ class SiteGroupTable(BaseTable):
|
||||
#
|
||||
|
||||
class SiteTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
region = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
group = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
asn_count = LinkedCountColumn(
|
||||
asn_count = columns.LinkedCountColumn(
|
||||
accessor=tables.A('asns.count'),
|
||||
viewname='ipam:asn_list',
|
||||
url_params={'site_id': 'pk'},
|
||||
verbose_name='ASNs'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:site_list'
|
||||
)
|
||||
|
||||
@@ -110,28 +108,28 @@ class SiteTable(BaseTable):
|
||||
#
|
||||
|
||||
class LocationTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = MPTTColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
name = columns.MPTTColumn(
|
||||
linkify=True
|
||||
)
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
rack_count = LinkedCountColumn(
|
||||
rack_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:rack_list',
|
||||
url_params={'location_id': 'pk'},
|
||||
verbose_name='Racks'
|
||||
)
|
||||
device_count = LinkedCountColumn(
|
||||
device_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'location_id': 'pk'},
|
||||
verbose_name='Devices'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='dcim:location_list'
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=LOCATION_BUTTONS
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user