Procházet zdrojové kódy

Refactor tables modules

jeremystretch před 4 roky
rodič
revize
d4d2af46ac

+ 3 - 0
netbox/circuits/tables/__init__.py

@@ -0,0 +1,3 @@
+from .circuits import *
+from .columns import *
+from .providers import *

+ 2 - 83
netbox/circuits/tables.py → netbox/circuits/tables/circuits.py

@@ -1,15 +1,13 @@
 import django_tables2 as tables
 import django_tables2 as tables
-from django_tables2.utils import Accessor
 
 
+from circuits.models import *
 from netbox.tables import NetBoxTable, columns
 from netbox.tables import NetBoxTable, columns
 from tenancy.tables import TenantColumn
 from tenancy.tables import TenantColumn
-from .models import *
+from .columns import CommitRateColumn
 
 
 __all__ = (
 __all__ = (
     'CircuitTable',
     'CircuitTable',
     'CircuitTypeTable',
     'CircuitTypeTable',
-    'ProviderTable',
-    'ProviderNetworkTable',
 )
 )
 
 
 
 
@@ -22,81 +20,6 @@ CIRCUITTERMINATION_LINK = """
 """
 """
 
 
 
 
-#
-# Table columns
-#
-
-class CommitRateColumn(tables.TemplateColumn):
-    """
-    Humanize the commit rate in the column view
-    """
-
-    template_code = """
-        {% load helpers %}
-        {{ record.commit_rate|humanize_speed }}
-        """
-
-    def __init__(self, *args, **kwargs):
-        super().__init__(template_code=self.template_code, *args, **kwargs)
-
-    def value(self, value):
-        return str(value) if value else None
-
-
-#
-# Providers
-#
-
-class ProviderTable(NetBoxTable):
-    name = tables.Column(
-        linkify=True
-    )
-    circuit_count = tables.Column(
-        accessor=Accessor('count_circuits'),
-        verbose_name='Circuits'
-    )
-    comments = columns.MarkdownColumn()
-    tags = columns.TagColumn(
-        url_name='circuits:provider_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = Provider
-        fields = (
-            'pk', 'id', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count',
-            'comments', 'tags', 'created', 'last_updated',
-        )
-        default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')
-
-
-#
-# Provider networks
-#
-
-class ProviderNetworkTable(NetBoxTable):
-    name = tables.Column(
-        linkify=True
-    )
-    provider = tables.Column(
-        linkify=True
-    )
-    comments = columns.MarkdownColumn()
-    tags = columns.TagColumn(
-        url_name='circuits:providernetwork_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = ProviderNetwork
-        fields = (
-            'pk', 'id', 'name', 'provider', 'service_id', 'description', 'comments', 'created', 'last_updated', 'tags',
-        )
-        default_columns = ('pk', 'name', 'provider', 'service_id', 'description')
-
-
-#
-# Circuit types
-#
-
 class CircuitTypeTable(NetBoxTable):
 class CircuitTypeTable(NetBoxTable):
     name = tables.Column(
     name = tables.Column(
         linkify=True
         linkify=True
@@ -116,10 +39,6 @@ class CircuitTypeTable(NetBoxTable):
         default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug')
         default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug')
 
 
 
 
-#
-# Circuits
-#
-
 class CircuitTable(NetBoxTable):
 class CircuitTable(NetBoxTable):
     cid = tables.Column(
     cid = tables.Column(
         linkify=True,
         linkify=True,

+ 21 - 0
netbox/circuits/tables/columns.py

@@ -0,0 +1,21 @@
+import django_tables2 as tables
+
+__all__ = (
+    'CommitRateColumn',
+)
+
+
+class CommitRateColumn(tables.TemplateColumn):
+    """
+    Humanize the commit rate in the column view
+    """
+    template_code = """
+        {% load helpers %}
+        {{ record.commit_rate|humanize_speed }}
+        """
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(template_code=self.template_code, *args, **kwargs)
+
+    def value(self, value):
+        return str(value) if value else None

+ 52 - 0
netbox/circuits/tables/providers.py

@@ -0,0 +1,52 @@
+import django_tables2 as tables
+from django_tables2.utils import Accessor
+
+from circuits.models import *
+from netbox.tables import NetBoxTable, columns
+
+__all__ = (
+    'ProviderTable',
+    'ProviderNetworkTable',
+)
+
+
+class ProviderTable(NetBoxTable):
+    name = tables.Column(
+        linkify=True
+    )
+    circuit_count = tables.Column(
+        accessor=Accessor('count_circuits'),
+        verbose_name='Circuits'
+    )
+    comments = columns.MarkdownColumn()
+    tags = columns.TagColumn(
+        url_name='circuits:provider_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = Provider
+        fields = (
+            'pk', 'id', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count',
+            'comments', 'tags', 'created', 'last_updated',
+        )
+        default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')
+
+
+class ProviderNetworkTable(NetBoxTable):
+    name = tables.Column(
+        linkify=True
+    )
+    provider = tables.Column(
+        linkify=True
+    )
+    comments = columns.MarkdownColumn()
+    tags = columns.TagColumn(
+        url_name='circuits:providernetwork_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = ProviderNetwork
+        fields = (
+            'pk', 'id', 'name', 'provider', 'service_id', 'description', 'comments', 'created', 'last_updated', 'tags',
+        )
+        default_columns = ('pk', 'name', 'provider', 'service_id', 'description')

+ 0 - 1
netbox/dcim/tables/devicetypes.py

@@ -1,5 +1,4 @@
 import django_tables2 as tables
 import django_tables2 as tables
-from django_tables2.utils import Accessor
 
 
 from dcim.models import (
 from dcim.models import (
     ConsolePortTemplate, ConsoleServerPortTemplate, DeviceBayTemplate, DeviceType, FrontPortTemplate, InterfaceTemplate,
     ConsolePortTemplate, ConsoleServerPortTemplate, DeviceBayTemplate, DeviceType, FrontPortTemplate, InterfaceTemplate,

+ 1 - 0
netbox/extras/tables/__init__.py

@@ -0,0 +1 @@
+from .tables import *

+ 2 - 27
netbox/extras/tables.py → netbox/extras/tables/tables.py

@@ -1,8 +1,9 @@
 import django_tables2 as tables
 import django_tables2 as tables
 from django.conf import settings
 from django.conf import settings
 
 
+from extras.models import *
 from netbox.tables import NetBoxTable, columns
 from netbox.tables import NetBoxTable, columns
-from .models import *
+from .template_code import *
 
 
 __all__ = (
 __all__ = (
     'ConfigContextTable',
     'ConfigContextTable',
@@ -17,32 +18,6 @@ __all__ = (
     'WebhookTable',
     'WebhookTable',
 )
 )
 
 
-CONFIGCONTEXT_ACTIONS = """
-{% if perms.extras.change_configcontext %}
-    <a href="{% url 'extras:configcontext_edit' pk=record.pk %}" class="btn btn-sm btn-warning"><i class="mdi mdi-pencil" aria-hidden="true"></i></a>
-{% endif %}
-{% if perms.extras.delete_configcontext %}
-    <a href="{% url 'extras:configcontext_delete' pk=record.pk %}" class="btn btn-sm btn-danger"><i class="mdi mdi-trash-can-outline" aria-hidden="true"></i></a>
-{% endif %}
-"""
-
-OBJECTCHANGE_FULL_NAME = """
-{% load helpers %}
-{{ record.user.get_full_name|placeholder }}
-"""
-
-OBJECTCHANGE_OBJECT = """
-{% if record.changed_object and record.changed_object.get_absolute_url %}
-    <a href="{{ record.changed_object.get_absolute_url }}">{{ record.object_repr }}</a>
-{% else %}
-    {{ record.object_repr }}
-{% endif %}
-"""
-
-OBJECTCHANGE_REQUEST_ID = """
-<a href="{% url 'extras:objectchange_list' %}?request_id={{ value }}">{{ value }}</a>
-"""
-
 
 
 #
 #
 # Custom fields
 # Custom fields

+ 25 - 0
netbox/extras/tables/template_code.py

@@ -0,0 +1,25 @@
+CONFIGCONTEXT_ACTIONS = """
+{% if perms.extras.change_configcontext %}
+    <a href="{% url 'extras:configcontext_edit' pk=record.pk %}" class="btn btn-sm btn-warning"><i class="mdi mdi-pencil" aria-hidden="true"></i></a>
+{% endif %}
+{% if perms.extras.delete_configcontext %}
+    <a href="{% url 'extras:configcontext_delete' pk=record.pk %}" class="btn btn-sm btn-danger"><i class="mdi mdi-trash-can-outline" aria-hidden="true"></i></a>
+{% endif %}
+"""
+
+OBJECTCHANGE_FULL_NAME = """
+{% load helpers %}
+{{ record.user.get_full_name|placeholder }}
+"""
+
+OBJECTCHANGE_OBJECT = """
+{% if record.changed_object and record.changed_object.get_absolute_url %}
+    <a href="{{ record.changed_object.get_absolute_url }}">{{ record.object_repr }}</a>
+{% else %}
+    {{ record.object_repr }}
+{% endif %}
+"""
+
+OBJECTCHANGE_REQUEST_ID = """
+<a href="{% url 'extras:objectchange_list' %}?request_id={{ value }}">{{ value }}</a>
+"""

+ 3 - 0
netbox/tenancy/tables/__init__.py

@@ -0,0 +1,3 @@
+from .columns import *
+from .contacts import *
+from .tenants import *

+ 26 - 0
netbox/tenancy/tables/columns.py

@@ -0,0 +1,26 @@
+import django_tables2 as tables
+
+__all__ = (
+    'TenantColumn',
+)
+
+
+class TenantColumn(tables.TemplateColumn):
+    """
+    Include the tenant description.
+    """
+    template_code = """
+    {% if record.tenant %}
+        <a href="{{ record.tenant.get_absolute_url }}" title="{{ record.tenant.description }}">{{ record.tenant }}</a>
+    {% elif record.vrf.tenant %}
+        <a href="{{ record.vrf.tenant.get_absolute_url }}" title="{{ record.vrf.tenant.description }}">{{ record.vrf.tenant }}</a>*
+    {% else %}
+        &mdash;
+    {% endif %}
+    """
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(template_code=self.template_code, *args, **kwargs)
+
+    def value(self, value):
+        return str(value) if value else None

+ 1 - 76
netbox/tenancy/tables.py → netbox/tenancy/tables/contacts.py

@@ -1,92 +1,17 @@
 import django_tables2 as tables
 import django_tables2 as tables
 
 
 from netbox.tables import NetBoxTable, columns
 from netbox.tables import NetBoxTable, columns
+from tenancy.models import *
 from utilities.tables import linkify_phone
 from utilities.tables import linkify_phone
-from .models import *
 
 
 __all__ = (
 __all__ = (
     'ContactAssignmentTable',
     'ContactAssignmentTable',
     'ContactGroupTable',
     'ContactGroupTable',
     'ContactRoleTable',
     'ContactRoleTable',
     'ContactTable',
     'ContactTable',
-    'TenantColumn',
-    'TenantGroupTable',
-    'TenantTable',
 )
 )
 
 
 
 
-#
-# Table columns
-#
-
-class TenantColumn(tables.TemplateColumn):
-    """
-    Include the tenant description.
-    """
-    template_code = """
-    {% if record.tenant %}
-        <a href="{{ record.tenant.get_absolute_url }}" title="{{ record.tenant.description }}">{{ record.tenant }}</a>
-    {% elif record.vrf.tenant %}
-        <a href="{{ record.vrf.tenant.get_absolute_url }}" title="{{ record.vrf.tenant.description }}">{{ record.vrf.tenant }}</a>*
-    {% else %}
-        &mdash;
-    {% endif %}
-    """
-
-    def __init__(self, *args, **kwargs):
-        super().__init__(template_code=self.template_code, *args, **kwargs)
-
-    def value(self, value):
-        return str(value) if value else None
-
-
-#
-# Tenants
-#
-
-class TenantGroupTable(NetBoxTable):
-    name = columns.MPTTColumn(
-        linkify=True
-    )
-    tenant_count = columns.LinkedCountColumn(
-        viewname='tenancy:tenant_list',
-        url_params={'group_id': 'pk'},
-        verbose_name='Tenants'
-    )
-    tags = columns.TagColumn(
-        url_name='tenancy:tenantgroup_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = TenantGroup
-        fields = (
-            'pk', 'id', 'name', 'tenant_count', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
-        )
-        default_columns = ('pk', 'name', 'tenant_count', 'description')
-
-
-class TenantTable(NetBoxTable):
-    name = tables.Column(
-        linkify=True
-    )
-    group = tables.Column(
-        linkify=True
-    )
-    comments = columns.MarkdownColumn()
-    tags = columns.TagColumn(
-        url_name='tenancy:tenant_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = Tenant
-        fields = ('pk', 'id', 'name', 'slug', 'group', 'description', 'comments', 'tags', 'created', 'last_updated',)
-        default_columns = ('pk', 'name', 'group', 'description')
-
-
-#
-# Contacts
-#
-
 class ContactGroupTable(NetBoxTable):
 class ContactGroupTable(NetBoxTable):
     name = columns.MPTTColumn(
     name = columns.MPTTColumn(
         linkify=True
         linkify=True

+ 48 - 0
netbox/tenancy/tables/tenants.py

@@ -0,0 +1,48 @@
+import django_tables2 as tables
+
+from netbox.tables import NetBoxTable, columns
+from tenancy.models import *
+
+__all__ = (
+    'TenantGroupTable',
+    'TenantTable',
+)
+
+
+class TenantGroupTable(NetBoxTable):
+    name = columns.MPTTColumn(
+        linkify=True
+    )
+    tenant_count = columns.LinkedCountColumn(
+        viewname='tenancy:tenant_list',
+        url_params={'group_id': 'pk'},
+        verbose_name='Tenants'
+    )
+    tags = columns.TagColumn(
+        url_name='tenancy:tenantgroup_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = TenantGroup
+        fields = (
+            'pk', 'id', 'name', 'tenant_count', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
+        )
+        default_columns = ('pk', 'name', 'tenant_count', 'description')
+
+
+class TenantTable(NetBoxTable):
+    name = tables.Column(
+        linkify=True
+    )
+    group = tables.Column(
+        linkify=True
+    )
+    comments = columns.MarkdownColumn()
+    tags = columns.TagColumn(
+        url_name='tenancy:tenant_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = Tenant
+        fields = ('pk', 'id', 'name', 'slug', 'group', 'description', 'comments', 'tags', 'created', 'last_updated',)
+        default_columns = ('pk', 'name', 'group', 'description')

+ 2 - 0
netbox/virtualization/tables/__init__.py

@@ -0,0 +1,2 @@
+from .clusters import *
+from .virtualmachines import *

+ 88 - 0
netbox/virtualization/tables/clusters.py

@@ -0,0 +1,88 @@
+import django_tables2 as tables
+
+from netbox.tables import NetBoxTable, columns
+from virtualization.models import Cluster, ClusterGroup, ClusterType
+
+__all__ = (
+    'ClusterTable',
+    'ClusterGroupTable',
+    'ClusterTypeTable',
+)
+
+
+class ClusterTypeTable(NetBoxTable):
+    name = tables.Column(
+        linkify=True
+    )
+    cluster_count = tables.Column(
+        verbose_name='Clusters'
+    )
+    tags = columns.TagColumn(
+        url_name='virtualization:clustertype_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = ClusterType
+        fields = (
+            'pk', 'id', 'name', 'slug', 'cluster_count', 'description', 'created', 'last_updated', 'tags', 'actions',
+        )
+        default_columns = ('pk', 'name', 'cluster_count', 'description')
+
+
+class ClusterGroupTable(NetBoxTable):
+    name = tables.Column(
+        linkify=True
+    )
+    cluster_count = tables.Column(
+        verbose_name='Clusters'
+    )
+    tags = columns.TagColumn(
+        url_name='virtualization:clustergroup_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = ClusterGroup
+        fields = (
+            'pk', 'id', 'name', 'slug', 'cluster_count', 'description', 'tags', 'created', 'last_updated', 'actions',
+        )
+        default_columns = ('pk', 'name', 'cluster_count', 'description')
+
+
+class ClusterTable(NetBoxTable):
+    name = tables.Column(
+        linkify=True
+    )
+    type = tables.Column(
+        linkify=True
+    )
+    group = tables.Column(
+        linkify=True
+    )
+    tenant = tables.Column(
+        linkify=True
+    )
+    site = tables.Column(
+        linkify=True
+    )
+    device_count = columns.LinkedCountColumn(
+        viewname='dcim:device_list',
+        url_params={'cluster_id': 'pk'},
+        verbose_name='Devices'
+    )
+    vm_count = columns.LinkedCountColumn(
+        viewname='virtualization:virtualmachine_list',
+        url_params={'cluster_id': 'pk'},
+        verbose_name='VMs'
+    )
+    comments = columns.MarkdownColumn()
+    tags = columns.TagColumn(
+        url_name='virtualization:cluster_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = Cluster
+        fields = (
+            'pk', 'id', 'name', 'type', 'group', 'tenant', 'site', 'comments', 'device_count', 'vm_count', 'tags',
+            'created', 'last_updated',
+        )
+        default_columns = ('pk', 'name', 'type', 'group', 'tenant', 'site', 'device_count', 'vm_count')

+ 1 - 94
netbox/virtualization/tables.py → netbox/virtualization/tables/virtualmachines.py

@@ -3,12 +3,9 @@ import django_tables2 as tables
 from dcim.tables.devices import BaseInterfaceTable
 from dcim.tables.devices import BaseInterfaceTable
 from netbox.tables import NetBoxTable, columns
 from netbox.tables import NetBoxTable, columns
 from tenancy.tables import TenantColumn
 from tenancy.tables import TenantColumn
-from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine, VMInterface
+from virtualization.models import VirtualMachine, VMInterface
 
 
 __all__ = (
 __all__ = (
-    'ClusterTable',
-    'ClusterGroupTable',
-    'ClusterTypeTable',
     'VirtualMachineTable',
     'VirtualMachineTable',
     'VirtualMachineVMInterfaceTable',
     'VirtualMachineVMInterfaceTable',
     'VMInterfaceTable',
     'VMInterfaceTable',
@@ -23,96 +20,6 @@ VMINTERFACE_BUTTONS = """
 """
 """
 
 
 
 
-#
-# Cluster types
-#
-
-class ClusterTypeTable(NetBoxTable):
-    name = tables.Column(
-        linkify=True
-    )
-    cluster_count = tables.Column(
-        verbose_name='Clusters'
-    )
-    tags = columns.TagColumn(
-        url_name='virtualization:clustertype_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = ClusterType
-        fields = (
-            'pk', 'id', 'name', 'slug', 'cluster_count', 'description', 'created', 'last_updated', 'tags', 'actions',
-        )
-        default_columns = ('pk', 'name', 'cluster_count', 'description')
-
-
-#
-# Cluster groups
-#
-
-class ClusterGroupTable(NetBoxTable):
-    name = tables.Column(
-        linkify=True
-    )
-    cluster_count = tables.Column(
-        verbose_name='Clusters'
-    )
-    tags = columns.TagColumn(
-        url_name='virtualization:clustergroup_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = ClusterGroup
-        fields = (
-            'pk', 'id', 'name', 'slug', 'cluster_count', 'description', 'tags', 'created', 'last_updated', 'actions',
-        )
-        default_columns = ('pk', 'name', 'cluster_count', 'description')
-
-
-#
-# Clusters
-#
-
-class ClusterTable(NetBoxTable):
-    name = tables.Column(
-        linkify=True
-    )
-    type = tables.Column(
-        linkify=True
-    )
-    group = tables.Column(
-        linkify=True
-    )
-    tenant = tables.Column(
-        linkify=True
-    )
-    site = tables.Column(
-        linkify=True
-    )
-    device_count = columns.LinkedCountColumn(
-        viewname='dcim:device_list',
-        url_params={'cluster_id': 'pk'},
-        verbose_name='Devices'
-    )
-    vm_count = columns.LinkedCountColumn(
-        viewname='virtualization:virtualmachine_list',
-        url_params={'cluster_id': 'pk'},
-        verbose_name='VMs'
-    )
-    comments = columns.MarkdownColumn()
-    tags = columns.TagColumn(
-        url_name='virtualization:cluster_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = Cluster
-        fields = (
-            'pk', 'id', 'name', 'type', 'group', 'tenant', 'site', 'comments', 'device_count', 'vm_count', 'tags',
-            'created', 'last_updated',
-        )
-        default_columns = ('pk', 'name', 'type', 'group', 'tenant', 'site', 'device_count', 'vm_count')
-
-
 #
 #
 # Virtual machines
 # Virtual machines
 #
 #

+ 2 - 0
netbox/wireless/tables/__init__.py

@@ -0,0 +1,2 @@
+from .wirelesslan import *
+from .wirelesslink import *

+ 3 - 39
netbox/wireless/tables.py → netbox/wireless/tables/wirelesslan.py

@@ -2,12 +2,12 @@ import django_tables2 as tables
 
 
 from dcim.models import Interface
 from dcim.models import Interface
 from netbox.tables import NetBoxTable, columns
 from netbox.tables import NetBoxTable, columns
-from .models import *
+from wireless.models import *
 
 
 __all__ = (
 __all__ = (
-    'WirelessLANTable',
     'WirelessLANGroupTable',
     'WirelessLANGroupTable',
-    'WirelessLinkTable',
+    'WirelessLANInterfacesTable',
+    'WirelessLANTable',
 )
 )
 
 
 
 
@@ -67,39 +67,3 @@ class WirelessLANInterfacesTable(NetBoxTable):
         model = Interface
         model = Interface
         fields = ('pk', 'device', 'name', 'rf_role', 'rf_channel')
         fields = ('pk', 'device', 'name', 'rf_role', 'rf_channel')
         default_columns = ('pk', 'device', 'name', 'rf_role', 'rf_channel')
         default_columns = ('pk', 'device', 'name', 'rf_role', 'rf_channel')
-
-
-class WirelessLinkTable(NetBoxTable):
-    id = tables.Column(
-        linkify=True,
-        verbose_name='ID'
-    )
-    status = columns.ChoiceFieldColumn()
-    device_a = tables.Column(
-        accessor=tables.A('interface_a__device'),
-        linkify=True
-    )
-    interface_a = tables.Column(
-        linkify=True
-    )
-    device_b = tables.Column(
-        accessor=tables.A('interface_b__device'),
-        linkify=True
-    )
-    interface_b = tables.Column(
-        linkify=True
-    )
-    tags = columns.TagColumn(
-        url_name='wireless:wirelesslink_list'
-    )
-
-    class Meta(NetBoxTable.Meta):
-        model = WirelessLink
-        fields = (
-            'pk', 'id', 'status', 'device_a', 'interface_a', 'device_b', 'interface_b', 'ssid', 'description',
-            'auth_type', 'auth_cipher', 'auth_psk', 'tags', 'created', 'last_updated',
-        )
-        default_columns = (
-            'pk', 'id', 'status', 'device_a', 'interface_a', 'device_b', 'interface_b', 'ssid', 'auth_type',
-            'description',
-        )

+ 44 - 0
netbox/wireless/tables/wirelesslink.py

@@ -0,0 +1,44 @@
+import django_tables2 as tables
+
+from netbox.tables import NetBoxTable, columns
+from wireless.models import *
+
+__all__ = (
+    'WirelessLinkTable',
+)
+
+
+class WirelessLinkTable(NetBoxTable):
+    id = tables.Column(
+        linkify=True,
+        verbose_name='ID'
+    )
+    status = columns.ChoiceFieldColumn()
+    device_a = tables.Column(
+        accessor=tables.A('interface_a__device'),
+        linkify=True
+    )
+    interface_a = tables.Column(
+        linkify=True
+    )
+    device_b = tables.Column(
+        accessor=tables.A('interface_b__device'),
+        linkify=True
+    )
+    interface_b = tables.Column(
+        linkify=True
+    )
+    tags = columns.TagColumn(
+        url_name='wireless:wirelesslink_list'
+    )
+
+    class Meta(NetBoxTable.Meta):
+        model = WirelessLink
+        fields = (
+            'pk', 'id', 'status', 'device_a', 'interface_a', 'device_b', 'interface_b', 'ssid', 'description',
+            'auth_type', 'auth_cipher', 'auth_psk', 'tags', 'created', 'last_updated',
+        )
+        default_columns = (
+            'pk', 'id', 'status', 'device_a', 'interface_a', 'device_b', 'interface_b', 'ssid', 'auth_type',
+            'description',
+        )