mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Closes #8469: Move BaseTable, columns to netbox core app
This commit is contained in:
parent
083d1acb81
commit
4a1b4e0485
@ -1,11 +1,10 @@
|
||||
import django_tables2 as tables
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import BaseTable, ChoiceFieldColumn, MarkdownColumn, TagColumn, ToggleColumn
|
||||
from .models import *
|
||||
|
||||
|
||||
__all__ = (
|
||||
'CircuitTable',
|
||||
'CircuitTypeTable',
|
||||
@ -22,11 +21,11 @@ CIRCUITTERMINATION_LINK = """
|
||||
{% endif %}
|
||||
"""
|
||||
|
||||
|
||||
#
|
||||
# Table columns
|
||||
#
|
||||
|
||||
|
||||
class CommitRateColumn(tables.TemplateColumn):
|
||||
"""
|
||||
Humanize the commit rate in the column view
|
||||
@ -43,13 +42,13 @@ class CommitRateColumn(tables.TemplateColumn):
|
||||
def value(self, value):
|
||||
return str(value) if value else None
|
||||
|
||||
|
||||
#
|
||||
# Providers
|
||||
#
|
||||
|
||||
|
||||
class ProviderTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -57,8 +56,8 @@ class ProviderTable(BaseTable):
|
||||
accessor=Accessor('count_circuits'),
|
||||
verbose_name='Circuits'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='circuits:provider_list'
|
||||
)
|
||||
|
||||
@ -76,15 +75,15 @@ class ProviderTable(BaseTable):
|
||||
#
|
||||
|
||||
class ProviderNetworkTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
provider = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='circuits:providernetwork_list'
|
||||
)
|
||||
|
||||
@ -101,11 +100,11 @@ class ProviderNetworkTable(BaseTable):
|
||||
#
|
||||
|
||||
class CircuitTypeTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='circuits:circuittype_list'
|
||||
)
|
||||
circuit_count = tables.Column(
|
||||
@ -125,7 +124,7 @@ class CircuitTypeTable(BaseTable):
|
||||
#
|
||||
|
||||
class CircuitTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
cid = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='Circuit ID'
|
||||
@ -133,7 +132,7 @@ class CircuitTable(BaseTable):
|
||||
provider = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
termination_a = tables.TemplateColumn(
|
||||
template_code=CIRCUITTERMINATION_LINK,
|
||||
@ -144,8 +143,8 @@ class CircuitTable(BaseTable):
|
||||
verbose_name='Side Z'
|
||||
)
|
||||
commit_rate = CommitRateColumn()
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='circuits:circuit_list'
|
||||
)
|
||||
|
||||
|
@ -5,10 +5,9 @@ from django.shortcuts import get_object_or_404, redirect, render
|
||||
|
||||
from netbox.views import generic
|
||||
from utilities.forms import ConfirmationForm
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import count_related
|
||||
from . import filtersets, forms, tables
|
||||
from .choices import CircuitTerminationSideChoices
|
||||
from .models import *
|
||||
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -20,7 +20,7 @@ from netbox.views import generic
|
||||
from utilities.forms import ConfirmationForm
|
||||
from utilities.paginator import EnhancedPaginator, get_paginate_count
|
||||
from utilities.permissions import get_permission_for_model
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import count_related
|
||||
from utilities.views import GetReturnURLMixin, ObjectPermissionRequiredMixin
|
||||
from virtualization.models import VirtualMachine
|
||||
|
@ -1,10 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
from django.conf import settings
|
||||
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, BooleanColumn, ChoiceFieldColumn, ColorColumn, ContentTypeColumn, ContentTypesColumn,
|
||||
MarkdownColumn, ToggleColumn,
|
||||
)
|
||||
from netbox.tables import BaseTable, columns
|
||||
from .models import *
|
||||
|
||||
__all__ = (
|
||||
@ -47,12 +44,12 @@ OBJECTCHANGE_REQUEST_ID = """
|
||||
#
|
||||
|
||||
class CustomFieldTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
content_types = ContentTypesColumn()
|
||||
required = BooleanColumn()
|
||||
content_types = columns.ContentTypesColumn()
|
||||
required = columns.BooleanColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = CustomField
|
||||
@ -68,13 +65,13 @@ class CustomFieldTable(BaseTable):
|
||||
#
|
||||
|
||||
class CustomLinkTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
content_type = ContentTypeColumn()
|
||||
enabled = BooleanColumn()
|
||||
new_window = BooleanColumn()
|
||||
content_type = columns.ContentTypeColumn()
|
||||
enabled = columns.BooleanColumn()
|
||||
new_window = columns.BooleanColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = CustomLink
|
||||
@ -90,12 +87,12 @@ class CustomLinkTable(BaseTable):
|
||||
#
|
||||
|
||||
class ExportTemplateTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
content_type = ContentTypeColumn()
|
||||
as_attachment = BooleanColumn()
|
||||
content_type = columns.ContentTypeColumn()
|
||||
as_attachment = columns.BooleanColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = ExportTemplate
|
||||
@ -113,22 +110,22 @@ class ExportTemplateTable(BaseTable):
|
||||
#
|
||||
|
||||
class WebhookTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
content_types = ContentTypesColumn()
|
||||
enabled = BooleanColumn()
|
||||
type_create = BooleanColumn(
|
||||
content_types = columns.ContentTypesColumn()
|
||||
enabled = columns.BooleanColumn()
|
||||
type_create = columns.BooleanColumn(
|
||||
verbose_name='Create'
|
||||
)
|
||||
type_update = BooleanColumn(
|
||||
type_update = columns.BooleanColumn(
|
||||
verbose_name='Update'
|
||||
)
|
||||
type_delete = BooleanColumn(
|
||||
type_delete = columns.BooleanColumn(
|
||||
verbose_name='Delete'
|
||||
)
|
||||
ssl_validation = BooleanColumn(
|
||||
ssl_validation = columns.BooleanColumn(
|
||||
verbose_name='SSL Validation'
|
||||
)
|
||||
|
||||
@ -149,11 +146,11 @@ class WebhookTable(BaseTable):
|
||||
#
|
||||
|
||||
class TagTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
color = ColorColumn()
|
||||
color = columns.ColorColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = Tag
|
||||
@ -167,7 +164,7 @@ class TaggedItemTable(BaseTable):
|
||||
linkify=lambda record: record.content_object.get_absolute_url(),
|
||||
accessor='content_object__id'
|
||||
)
|
||||
content_type = ContentTypeColumn(
|
||||
content_type = columns.ContentTypeColumn(
|
||||
verbose_name='Type'
|
||||
)
|
||||
content_object = tables.Column(
|
||||
@ -182,11 +179,11 @@ class TaggedItemTable(BaseTable):
|
||||
|
||||
|
||||
class ConfigContextTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
is_active = BooleanColumn(
|
||||
is_active = columns.BooleanColumn(
|
||||
verbose_name='Active'
|
||||
)
|
||||
|
||||
@ -205,8 +202,8 @@ class ObjectChangeTable(BaseTable):
|
||||
linkify=True,
|
||||
format=settings.SHORT_DATETIME_FORMAT
|
||||
)
|
||||
action = ChoiceFieldColumn()
|
||||
changed_object_type = ContentTypeColumn(
|
||||
action = columns.ChoiceFieldColumn()
|
||||
changed_object_type = columns.ContentTypeColumn(
|
||||
verbose_name='Type'
|
||||
)
|
||||
object_repr = tables.TemplateColumn(
|
||||
@ -217,7 +214,7 @@ class ObjectChangeTable(BaseTable):
|
||||
template_code=OBJECTCHANGE_REQUEST_ID,
|
||||
verbose_name='Request ID'
|
||||
)
|
||||
actions = ActionsColumn(sequence=())
|
||||
actions = columns.ActionsColumn(sequence=())
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = ObjectChange
|
||||
@ -232,7 +229,7 @@ class ObjectJournalTable(BaseTable):
|
||||
linkify=True,
|
||||
format=settings.SHORT_DATETIME_FORMAT
|
||||
)
|
||||
kind = ChoiceFieldColumn()
|
||||
kind = columns.ChoiceFieldColumn()
|
||||
comments = tables.TemplateColumn(
|
||||
template_code='{% load helpers %}{{ value|render_markdown|truncatewords_html:50 }}'
|
||||
)
|
||||
@ -243,8 +240,8 @@ class ObjectJournalTable(BaseTable):
|
||||
|
||||
|
||||
class JournalEntryTable(ObjectJournalTable):
|
||||
pk = ToggleColumn()
|
||||
assigned_object_type = ContentTypeColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
assigned_object_type = columns.ContentTypeColumn(
|
||||
verbose_name='Object type'
|
||||
)
|
||||
assigned_object = tables.Column(
|
||||
@ -252,7 +249,7 @@ class JournalEntryTable(ObjectJournalTable):
|
||||
orderable=False,
|
||||
verbose_name='Object'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
comments = columns.MarkdownColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = JournalEntry
|
||||
|
@ -11,7 +11,7 @@ from rq import Worker
|
||||
from netbox.views import generic
|
||||
from utilities.forms import ConfirmationForm
|
||||
from utilities.htmx import is_htmx
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import copy_safe_request, count_related, normalize_querydict, shallow_compare_dict
|
||||
from utilities.views import ContentTypePermissionRequiredMixin
|
||||
from . import filtersets, forms, tables
|
||||
|
@ -1,7 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from utilities.tables import ActionsColumn, BaseTable, MarkdownColumn, TagColumn, ToggleColumn
|
||||
from ipam.models import *
|
||||
from netbox.tables import BaseTable, columns
|
||||
|
||||
__all__ = (
|
||||
'FHRPGroupTable',
|
||||
@ -17,11 +17,11 @@ IPADDRESSES = """
|
||||
|
||||
|
||||
class FHRPGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
group_id = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
comments = columns.MarkdownColumn()
|
||||
ip_addresses = tables.TemplateColumn(
|
||||
template_code=IPADDRESSES,
|
||||
orderable=False,
|
||||
@ -30,7 +30,7 @@ class FHRPGroupTable(BaseTable):
|
||||
interface_count = tables.Column(
|
||||
verbose_name='Interfaces'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:fhrpgroup_list'
|
||||
)
|
||||
|
||||
@ -44,7 +44,7 @@ class FHRPGroupTable(BaseTable):
|
||||
|
||||
|
||||
class FHRPGroupAssignmentTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
interface_parent = tables.Column(
|
||||
accessor=tables.A('interface.parent_object'),
|
||||
linkify=True,
|
||||
@ -58,7 +58,7 @@ class FHRPGroupAssignmentTable(BaseTable):
|
||||
group = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
|
||||
|
@ -3,10 +3,8 @@ from django.utils.safestring import mark_safe
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from ipam.models import *
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import (
|
||||
BaseTable, BooleanColumn, ChoiceFieldColumn, LinkedCountColumn, TagColumn, ToggleColumn, UtilizationColumn,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
'AggregateTable',
|
||||
@ -73,19 +71,19 @@ VRF_LINK = """
|
||||
#
|
||||
|
||||
class RIRTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
is_private = BooleanColumn(
|
||||
is_private = columns.BooleanColumn(
|
||||
verbose_name='Private'
|
||||
)
|
||||
aggregate_count = LinkedCountColumn(
|
||||
aggregate_count = columns.LinkedCountColumn(
|
||||
viewname='ipam:aggregate_list',
|
||||
url_params={'rir_id': 'pk'},
|
||||
verbose_name='Aggregates'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:rir_list'
|
||||
)
|
||||
|
||||
@ -103,13 +101,13 @@ class RIRTable(BaseTable):
|
||||
#
|
||||
|
||||
class ASNTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
asn = tables.Column(
|
||||
accessor=tables.A('asn_asdot'),
|
||||
linkify=True
|
||||
)
|
||||
|
||||
site_count = LinkedCountColumn(
|
||||
site_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:site_list',
|
||||
url_params={'asn_id': 'pk'},
|
||||
verbose_name='Sites'
|
||||
@ -126,7 +124,7 @@ class ASNTable(BaseTable):
|
||||
#
|
||||
|
||||
class AggregateTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
prefix = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='Aggregate'
|
||||
@ -139,11 +137,11 @@ class AggregateTable(BaseTable):
|
||||
child_count = tables.Column(
|
||||
verbose_name='Prefixes'
|
||||
)
|
||||
utilization = UtilizationColumn(
|
||||
utilization = columns.UtilizationColumn(
|
||||
accessor='get_utilization',
|
||||
orderable=False
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:aggregate_list'
|
||||
)
|
||||
|
||||
@ -161,21 +159,21 @@ class AggregateTable(BaseTable):
|
||||
#
|
||||
|
||||
class RoleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
prefix_count = LinkedCountColumn(
|
||||
prefix_count = columns.LinkedCountColumn(
|
||||
viewname='ipam:prefix_list',
|
||||
url_params={'role_id': 'pk'},
|
||||
verbose_name='Prefixes'
|
||||
)
|
||||
vlan_count = LinkedCountColumn(
|
||||
vlan_count = columns.LinkedCountColumn(
|
||||
viewname='ipam:vlan_list',
|
||||
url_params={'role_id': 'pk'},
|
||||
verbose_name='VLANs'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:role_list'
|
||||
)
|
||||
|
||||
@ -192,7 +190,7 @@ class RoleTable(BaseTable):
|
||||
# Prefixes
|
||||
#
|
||||
|
||||
class PrefixUtilizationColumn(UtilizationColumn):
|
||||
class PrefixUtilizationColumn(columns.UtilizationColumn):
|
||||
"""
|
||||
Extend UtilizationColumn to allow disabling the warning & danger thresholds for prefixes
|
||||
marked as fully utilized.
|
||||
@ -208,7 +206,7 @@ class PrefixUtilizationColumn(UtilizationColumn):
|
||||
|
||||
|
||||
class PrefixTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
prefix = tables.TemplateColumn(
|
||||
template_code=PREFIX_LINK,
|
||||
attrs={'td': {'class': 'text-nowrap'}}
|
||||
@ -222,7 +220,7 @@ class PrefixTable(BaseTable):
|
||||
accessor=Accessor('_depth'),
|
||||
verbose_name='Depth'
|
||||
)
|
||||
children = LinkedCountColumn(
|
||||
children = columns.LinkedCountColumn(
|
||||
accessor=Accessor('_children'),
|
||||
viewname='ipam:prefix_list',
|
||||
url_params={
|
||||
@ -231,7 +229,7 @@ class PrefixTable(BaseTable):
|
||||
},
|
||||
verbose_name='Children'
|
||||
)
|
||||
status = ChoiceFieldColumn(
|
||||
status = columns.ChoiceFieldColumn(
|
||||
default=AVAILABLE_LABEL
|
||||
)
|
||||
vrf = tables.TemplateColumn(
|
||||
@ -254,17 +252,17 @@ class PrefixTable(BaseTable):
|
||||
role = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
is_pool = BooleanColumn(
|
||||
is_pool = columns.BooleanColumn(
|
||||
verbose_name='Pool'
|
||||
)
|
||||
mark_utilized = BooleanColumn(
|
||||
mark_utilized = columns.BooleanColumn(
|
||||
verbose_name='Marked Utilized'
|
||||
)
|
||||
utilization = PrefixUtilizationColumn(
|
||||
accessor='get_utilization',
|
||||
orderable=False
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:prefix_list'
|
||||
)
|
||||
|
||||
@ -286,7 +284,7 @@ class PrefixTable(BaseTable):
|
||||
# IP ranges
|
||||
#
|
||||
class IPRangeTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
start_address = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -294,18 +292,18 @@ class IPRangeTable(BaseTable):
|
||||
template_code=VRF_LINK,
|
||||
verbose_name='VRF'
|
||||
)
|
||||
status = ChoiceFieldColumn(
|
||||
status = columns.ChoiceFieldColumn(
|
||||
default=AVAILABLE_LABEL
|
||||
)
|
||||
role = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
utilization = UtilizationColumn(
|
||||
utilization = columns.UtilizationColumn(
|
||||
accessor='utilization',
|
||||
orderable=False
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:iprange_list'
|
||||
)
|
||||
|
||||
@ -328,7 +326,7 @@ class IPRangeTable(BaseTable):
|
||||
#
|
||||
|
||||
class IPAddressTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
address = tables.TemplateColumn(
|
||||
template_code=IPADDRESS_LINK,
|
||||
verbose_name='IP Address'
|
||||
@ -337,10 +335,10 @@ class IPAddressTable(BaseTable):
|
||||
template_code=VRF_LINK,
|
||||
verbose_name='VRF'
|
||||
)
|
||||
status = ChoiceFieldColumn(
|
||||
status = columns.ChoiceFieldColumn(
|
||||
default=AVAILABLE_LABEL
|
||||
)
|
||||
role = ChoiceFieldColumn()
|
||||
role = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
assigned_object = tables.Column(
|
||||
linkify=True,
|
||||
@ -358,12 +356,12 @@ class IPAddressTable(BaseTable):
|
||||
orderable=False,
|
||||
verbose_name='NAT (Inside)'
|
||||
)
|
||||
assigned = BooleanColumn(
|
||||
assigned = columns.BooleanColumn(
|
||||
accessor='assigned_object_id',
|
||||
linkify=True,
|
||||
verbose_name='Assigned'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:ipaddress_list'
|
||||
)
|
||||
|
||||
@ -386,7 +384,7 @@ class IPAddressAssignTable(BaseTable):
|
||||
template_code=IPADDRESS_ASSIGN_LINK,
|
||||
verbose_name='IP Address'
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
assigned_object = tables.Column(
|
||||
orderable=False
|
||||
)
|
||||
@ -410,7 +408,7 @@ class AssignedIPAddressesTable(BaseTable):
|
||||
template_code=VRF_LINK,
|
||||
verbose_name='VRF'
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
|
@ -1,7 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from utilities.tables import BaseTable, TagColumn, ToggleColumn
|
||||
from ipam.models import *
|
||||
from netbox.tables import BaseTable, columns
|
||||
|
||||
__all__ = (
|
||||
'ServiceTable',
|
||||
@ -10,14 +10,14 @@ __all__ = (
|
||||
|
||||
|
||||
class ServiceTemplateTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
ports = tables.Column(
|
||||
accessor=tables.A('port_list')
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:servicetemplate_list'
|
||||
)
|
||||
|
||||
@ -28,7 +28,7 @@ class ServiceTemplateTable(BaseTable):
|
||||
|
||||
|
||||
class ServiceTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -39,7 +39,7 @@ class ServiceTable(BaseTable):
|
||||
ports = tables.Column(
|
||||
accessor=tables.A('port_list')
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:service_list'
|
||||
)
|
||||
|
||||
|
@ -3,13 +3,10 @@ from django.utils.safestring import mark_safe
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from dcim.models import Interface
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, BooleanColumn, ChoiceFieldColumn, ContentTypeColumn, LinkedCountColumn, TagColumn,
|
||||
TemplateColumn, ToggleColumn,
|
||||
)
|
||||
from virtualization.models import VMInterface
|
||||
from ipam.models import *
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from virtualization.models import VMInterface
|
||||
|
||||
__all__ = (
|
||||
'InterfaceVLANTable',
|
||||
@ -62,22 +59,22 @@ VLAN_MEMBER_TAGGED = """
|
||||
#
|
||||
|
||||
class VLANGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(linkify=True)
|
||||
scope_type = ContentTypeColumn()
|
||||
scope_type = columns.ContentTypeColumn()
|
||||
scope = tables.Column(
|
||||
linkify=True,
|
||||
orderable=False
|
||||
)
|
||||
vlan_count = LinkedCountColumn(
|
||||
vlan_count = columns.LinkedCountColumn(
|
||||
viewname='ipam:vlan_list',
|
||||
url_params={'group_id': 'pk'},
|
||||
verbose_name='VLANs'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:vlangroup_list'
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
extra_buttons=VLANGROUP_BUTTONS
|
||||
)
|
||||
|
||||
@ -95,7 +92,7 @@ class VLANGroupTable(BaseTable):
|
||||
#
|
||||
|
||||
class VLANTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
vid = tables.TemplateColumn(
|
||||
template_code=VLAN_LINK,
|
||||
verbose_name='VID'
|
||||
@ -110,18 +107,18 @@ class VLANTable(BaseTable):
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
status = ChoiceFieldColumn(
|
||||
status = columns.ChoiceFieldColumn(
|
||||
default=AVAILABLE_LABEL
|
||||
)
|
||||
role = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
prefixes = TemplateColumn(
|
||||
prefixes = columns.TemplateColumn(
|
||||
template_code=VLAN_PREFIXES,
|
||||
orderable=False,
|
||||
verbose_name='Prefixes'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:vlan_list'
|
||||
)
|
||||
|
||||
@ -155,7 +152,7 @@ class VLANDevicesTable(VLANMembersTable):
|
||||
device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit',)
|
||||
)
|
||||
|
||||
@ -169,7 +166,7 @@ class VLANVirtualMachinesTable(VLANMembersTable):
|
||||
virtual_machine = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit',)
|
||||
)
|
||||
|
||||
@ -187,7 +184,7 @@ class InterfaceVLANTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='ID'
|
||||
)
|
||||
tagged = BooleanColumn()
|
||||
tagged = columns.BooleanColumn()
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -196,7 +193,7 @@ class InterfaceVLANTable(BaseTable):
|
||||
verbose_name='Group'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
role = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import BaseTable, BooleanColumn, TagColumn, TemplateColumn, ToggleColumn
|
||||
from ipam.models import *
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
|
||||
__all__ = (
|
||||
'RouteTargetTable',
|
||||
@ -21,7 +21,7 @@ VRF_TARGETS = """
|
||||
#
|
||||
|
||||
class VRFTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -29,18 +29,18 @@ class VRFTable(BaseTable):
|
||||
verbose_name='RD'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
enforce_unique = BooleanColumn(
|
||||
enforce_unique = columns.BooleanColumn(
|
||||
verbose_name='Unique'
|
||||
)
|
||||
import_targets = TemplateColumn(
|
||||
import_targets = columns.TemplateColumn(
|
||||
template_code=VRF_TARGETS,
|
||||
orderable=False
|
||||
)
|
||||
export_targets = TemplateColumn(
|
||||
export_targets = columns.TemplateColumn(
|
||||
template_code=VRF_TARGETS,
|
||||
orderable=False
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:vrf_list'
|
||||
)
|
||||
|
||||
@ -58,12 +58,12 @@ class VRFTable(BaseTable):
|
||||
#
|
||||
|
||||
class RouteTargetTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:vrf_list'
|
||||
)
|
||||
|
||||
|
@ -8,7 +8,7 @@ from dcim.filtersets import InterfaceFilterSet
|
||||
from dcim.models import Interface, Site
|
||||
from dcim.tables import SiteTable
|
||||
from netbox.views import generic
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import count_related
|
||||
from virtualization.filtersets import VMInterfaceFilterSet
|
||||
from virtualization.models import VMInterface
|
||||
|
@ -27,13 +27,3 @@ def configure_table(table, request):
|
||||
'per_page': get_paginate_count(request)
|
||||
}
|
||||
RequestConfig(request, paginate).configure(table)
|
||||
|
||||
|
||||
#
|
||||
# Callables
|
||||
#
|
||||
|
||||
def linkify_phone(value):
|
||||
if value is None:
|
||||
return None
|
||||
return f"tel:{value}"
|
@ -7,7 +7,7 @@ from django.db.models.fields.related import RelatedField
|
||||
from django_tables2.data import TableQuerysetData
|
||||
|
||||
from extras.models import CustomField, CustomLink
|
||||
from . import columns
|
||||
from netbox.tables import columns
|
||||
|
||||
__all__ = (
|
||||
'BaseTable',
|
@ -21,7 +21,7 @@ from utilities.forms import (
|
||||
)
|
||||
from utilities.htmx import is_htmx
|
||||
from utilities.permissions import get_permission_for_model
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.views import GetReturnURLMixin
|
||||
from .base import BaseMultiObjectView
|
||||
|
||||
|
@ -18,7 +18,7 @@ from utilities.exceptions import AbortTransaction, PermissionsViolation
|
||||
from utilities.forms import ConfirmationForm, ImportForm, restrict_form_fields
|
||||
from utilities.htmx import is_htmx
|
||||
from utilities.permissions import get_permission_for_model
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import normalize_querydict, prepare_cloned_fields
|
||||
from utilities.views import GetReturnURLMixin
|
||||
from .base import BaseObjectView
|
||||
|
@ -1,9 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, ContentTypeColumn, LinkedCountColumn, linkify_phone, MarkdownColumn, MPTTColumn,
|
||||
TagColumn, ToggleColumn,
|
||||
)
|
||||
from netbox.tables import BaseTable, columns
|
||||
from utilities.tables import linkify_phone
|
||||
from .models import *
|
||||
|
||||
__all__ = (
|
||||
@ -47,16 +45,16 @@ class TenantColumn(tables.TemplateColumn):
|
||||
#
|
||||
|
||||
class TenantGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = MPTTColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
name = columns.MPTTColumn(
|
||||
linkify=True
|
||||
)
|
||||
tenant_count = LinkedCountColumn(
|
||||
tenant_count = columns.LinkedCountColumn(
|
||||
viewname='tenancy:tenant_list',
|
||||
url_params={'group_id': 'pk'},
|
||||
verbose_name='Tenants'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='tenancy:tenantgroup_list'
|
||||
)
|
||||
|
||||
@ -69,15 +67,15 @@ class TenantGroupTable(BaseTable):
|
||||
|
||||
|
||||
class TenantTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
group = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='tenancy:tenant_list'
|
||||
)
|
||||
|
||||
@ -92,16 +90,16 @@ class TenantTable(BaseTable):
|
||||
#
|
||||
|
||||
class ContactGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = MPTTColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
name = columns.MPTTColumn(
|
||||
linkify=True
|
||||
)
|
||||
contact_count = LinkedCountColumn(
|
||||
contact_count = columns.LinkedCountColumn(
|
||||
viewname='tenancy:contact_list',
|
||||
url_params={'role_id': 'pk'},
|
||||
verbose_name='Contacts'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='tenancy:contactgroup_list'
|
||||
)
|
||||
|
||||
@ -114,7 +112,7 @@ class ContactGroupTable(BaseTable):
|
||||
|
||||
|
||||
class ContactRoleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -126,7 +124,7 @@ class ContactRoleTable(BaseTable):
|
||||
|
||||
|
||||
class ContactTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -136,11 +134,11 @@ class ContactTable(BaseTable):
|
||||
phone = tables.Column(
|
||||
linkify=linkify_phone,
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
comments = columns.MarkdownColumn()
|
||||
assignment_count = tables.Column(
|
||||
verbose_name='Assignments'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='tenancy:tenant_list'
|
||||
)
|
||||
|
||||
@ -154,8 +152,8 @@ class ContactTable(BaseTable):
|
||||
|
||||
|
||||
class ContactAssignmentTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
content_type = ContentTypeColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
content_type = columns.ContentTypeColumn(
|
||||
verbose_name='Object Type'
|
||||
)
|
||||
object = tables.Column(
|
||||
@ -168,7 +166,7 @@ class ContactAssignmentTable(BaseTable):
|
||||
role = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
|
||||
|
@ -6,7 +6,7 @@ from circuits.models import Circuit
|
||||
from dcim.models import Site, Rack, Device, RackReservation, Cable
|
||||
from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF
|
||||
from netbox.views import generic
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import count_related
|
||||
from virtualization.models import VirtualMachine, Cluster
|
||||
from . import filtersets, forms, tables
|
||||
|
@ -6,7 +6,7 @@ from django.urls import reverse
|
||||
from dcim.models import Site
|
||||
from dcim.tables import SiteTable
|
||||
from users.preferences import UserPreference
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.testing import TestCase
|
||||
|
||||
|
||||
|
7
netbox/utilities/tables.py
Normal file
7
netbox/utilities/tables.py
Normal file
@ -0,0 +1,7 @@
|
||||
def linkify_phone(value):
|
||||
"""
|
||||
Render a telephone number as a hyperlink.
|
||||
"""
|
||||
if value is None:
|
||||
return None
|
||||
return f"tel:{value}"
|
@ -2,12 +2,12 @@ from django.template import Context, Template
|
||||
from django.test import TestCase
|
||||
|
||||
from dcim.models import Site
|
||||
from utilities.tables import BaseTable, TagColumn
|
||||
from netbox.tables import BaseTable, columns
|
||||
from utilities.testing import create_tags
|
||||
|
||||
|
||||
class TagColumnTable(BaseTable):
|
||||
tags = TagColumn(url_name='dcim:site_list')
|
||||
tags = columns.TagColumn(url_name='dcim:site_list')
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = Site
|
||||
|
@ -1,11 +1,8 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from dcim.tables.devices import BaseInterfaceTable
|
||||
from netbox.tables import BaseTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from utilities.tables import (
|
||||
ActionsColumn, BaseTable, ChoiceFieldColumn, ColoredLabelColumn, LinkedCountColumn, MarkdownColumn, TagColumn,
|
||||
ToggleColumn,
|
||||
)
|
||||
from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine, VMInterface
|
||||
|
||||
__all__ = (
|
||||
@ -31,14 +28,14 @@ VMINTERFACE_BUTTONS = """
|
||||
#
|
||||
|
||||
class ClusterTypeTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
cluster_count = tables.Column(
|
||||
verbose_name='Clusters'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='virtualization:clustertype_list'
|
||||
)
|
||||
|
||||
@ -55,14 +52,14 @@ class ClusterTypeTable(BaseTable):
|
||||
#
|
||||
|
||||
class ClusterGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
cluster_count = tables.Column(
|
||||
verbose_name='Clusters'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='virtualization:clustergroup_list'
|
||||
)
|
||||
|
||||
@ -79,7 +76,7 @@ class ClusterGroupTable(BaseTable):
|
||||
#
|
||||
|
||||
class ClusterTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -95,18 +92,18 @@ class ClusterTable(BaseTable):
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
device_count = LinkedCountColumn(
|
||||
device_count = columns.LinkedCountColumn(
|
||||
viewname='dcim:device_list',
|
||||
url_params={'cluster_id': 'pk'},
|
||||
verbose_name='Devices'
|
||||
)
|
||||
vm_count = LinkedCountColumn(
|
||||
vm_count = columns.LinkedCountColumn(
|
||||
viewname='virtualization:virtualmachine_list',
|
||||
url_params={'cluster_id': 'pk'},
|
||||
verbose_name='VMs'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
tags = TagColumn(
|
||||
comments = columns.MarkdownColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='virtualization:cluster_list'
|
||||
)
|
||||
|
||||
@ -124,18 +121,18 @@ class ClusterTable(BaseTable):
|
||||
#
|
||||
|
||||
class VirtualMachineTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
name = tables.Column(
|
||||
order_by=('_name',),
|
||||
linkify=True
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
cluster = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
role = ColoredLabelColumn()
|
||||
role = columns.ColoredLabelColumn()
|
||||
tenant = TenantColumn()
|
||||
comments = MarkdownColumn()
|
||||
comments = columns.MarkdownColumn()
|
||||
primary_ip4 = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='IPv4 Address'
|
||||
@ -149,7 +146,7 @@ class VirtualMachineTable(BaseTable):
|
||||
order_by=('primary_ip4', 'primary_ip6'),
|
||||
verbose_name='IP Address'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='virtualization:virtualmachine_list'
|
||||
)
|
||||
|
||||
@ -169,14 +166,14 @@ class VirtualMachineTable(BaseTable):
|
||||
#
|
||||
|
||||
class VMInterfaceTable(BaseInterfaceTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
virtual_machine = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='virtualization:vminterface_list'
|
||||
)
|
||||
|
||||
@ -196,7 +193,7 @@ class VirtualMachineVMInterfaceTable(VMInterfaceTable):
|
||||
bridge = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions = columns.ActionsColumn(
|
||||
sequence=('edit', 'delete'),
|
||||
extra_buttons=VMINTERFACE_BUTTONS
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ from extras.views import ObjectConfigContextView
|
||||
from ipam.models import IPAddress, Service
|
||||
from ipam.tables import AssignedIPAddressesTable, InterfaceVLANTable
|
||||
from netbox.views import generic
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import count_related
|
||||
from . import filtersets, forms, tables
|
||||
from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine, VMInterface
|
||||
|
@ -1,7 +1,7 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
from dcim.models import Interface
|
||||
from utilities.tables import BaseTable, ChoiceFieldColumn, LinkedCountColumn, MPTTColumn, TagColumn, ToggleColumn
|
||||
from netbox.tables import BaseTable, columns
|
||||
from .models import *
|
||||
|
||||
__all__ = (
|
||||
@ -12,16 +12,16 @@ __all__ = (
|
||||
|
||||
|
||||
class WirelessLANGroupTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = MPTTColumn(
|
||||
pk = columns.ToggleColumn()
|
||||
name = columns.MPTTColumn(
|
||||
linkify=True
|
||||
)
|
||||
wirelesslan_count = LinkedCountColumn(
|
||||
wirelesslan_count = columns.LinkedCountColumn(
|
||||
viewname='wireless:wirelesslan_list',
|
||||
url_params={'group_id': 'pk'},
|
||||
verbose_name='Wireless LANs'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='wireless:wirelesslangroup_list'
|
||||
)
|
||||
|
||||
@ -34,7 +34,7 @@ class WirelessLANGroupTable(BaseTable):
|
||||
|
||||
|
||||
class WirelessLANTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
ssid = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -44,7 +44,7 @@ class WirelessLANTable(BaseTable):
|
||||
interface_count = tables.Column(
|
||||
verbose_name='Interfaces'
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='wireless:wirelesslan_list'
|
||||
)
|
||||
|
||||
@ -58,7 +58,7 @@ class WirelessLANTable(BaseTable):
|
||||
|
||||
|
||||
class WirelessLANInterfacesTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@ -73,12 +73,12 @@ class WirelessLANInterfacesTable(BaseTable):
|
||||
|
||||
|
||||
class WirelessLinkTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
pk = columns.ToggleColumn()
|
||||
id = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='ID'
|
||||
)
|
||||
status = ChoiceFieldColumn()
|
||||
status = columns.ChoiceFieldColumn()
|
||||
device_a = tables.Column(
|
||||
accessor=tables.A('interface_a__device'),
|
||||
linkify=True
|
||||
@ -93,7 +93,7 @@ class WirelessLinkTable(BaseTable):
|
||||
interface_b = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
tags = columns.TagColumn(
|
||||
url_name='wireless:wirelesslink_list'
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from dcim.models import Interface
|
||||
from netbox.views import generic
|
||||
from utilities.tables import configure_table
|
||||
from netbox.tables import configure_table
|
||||
from utilities.utils import count_related
|
||||
from . import filtersets, forms, tables
|
||||
from .models import *
|
||||
|
Loading…
Reference in New Issue
Block a user