1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

76 lines
2.0 KiB
Python
Raw Normal View History

2022-06-27 23:24:50 -05:00
import django_tables2 as tables
2022-07-11 21:51:39 -04:00
from ipam.models import L2VPN, L2VPNTermination
2022-06-27 23:24:50 -05:00
from netbox.tables import NetBoxTable, columns
2022-07-11 21:51:39 -04:00
from tenancy.tables import TenancyColumnsMixin
2022-06-27 23:24:50 -05:00
__all__ = (
'L2VPNTable',
'L2VPNTerminationTable',
)
2022-07-06 08:57:15 -05:00
L2VPN_TARGETS = """
{% for rt in value.all %}
<a href="{{ rt.get_absolute_url }}">{{ rt }}</a>{% if not forloop.last %}<br />{% endif %}
{% endfor %}
"""
2022-06-27 23:24:50 -05:00
2022-07-11 21:51:39 -04:00
class L2VPNTable(TenancyColumnsMixin, NetBoxTable):
2022-06-27 23:24:50 -05:00
pk = columns.ToggleColumn()
name = tables.Column(
linkify=True
)
2022-07-06 08:57:15 -05:00
import_targets = columns.TemplateColumn(
template_code=L2VPN_TARGETS,
orderable=False
)
export_targets = columns.TemplateColumn(
template_code=L2VPN_TARGETS,
orderable=False
)
2022-06-27 23:24:50 -05:00
class Meta(NetBoxTable.Meta):
model = L2VPN
2022-07-11 21:51:39 -04:00
fields = (
'pk', 'name', 'slug', 'type', 'description', 'import_targets', 'export_targets', 'tenant', 'tenant_group',
'actions', 'identifier',
2022-07-11 21:51:39 -04:00
)
2022-07-06 08:57:15 -05:00
default_columns = ('pk', 'name', 'type', 'description', 'actions')
2022-06-27 23:24:50 -05:00
class L2VPNTerminationTable(NetBoxTable):
pk = columns.ToggleColumn()
2022-07-06 08:57:15 -05:00
l2vpn = tables.Column(
verbose_name='L2VPN',
linkify=True
)
2022-06-27 23:24:50 -05:00
assigned_object_type = columns.ContentTypeColumn(
verbose_name='Object Type'
)
assigned_object = tables.Column(
linkify=True,
orderable=False,
verbose_name='Object'
2022-06-27 23:24:50 -05:00
)
assigned_object_parent = tables.Column(
linkify=True,
orderable=False,
verbose_name='Object Parent'
)
assigned_object_site = tables.Column(
linkify=True,
orderable=False,
verbose_name='Object Site'
)
2022-06-27 23:24:50 -05:00
class Meta(NetBoxTable.Meta):
model = L2VPNTermination
fields = (
'pk', 'l2vpn', 'assigned_object_type', 'assigned_object', 'assigned_object_parent', 'assigned_object_site',
'actions',
)
default_columns = (
'pk', 'l2vpn', 'assigned_object_type', 'assigned_object_parent', 'assigned_object', 'actions',
)