mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Extend Cable model to support multiple A/B terminations
This commit is contained in:
@@ -4,7 +4,7 @@ from django_tables2.utils import Accessor
|
||||
from dcim.models import Cable
|
||||
from netbox.tables import NetBoxTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from .template_code import CABLE_LENGTH, CABLE_TERMINATION_PARENT
|
||||
from .template_code import CABLE_LENGTH, CABLE_TERMINATION, CABLE_TERMINATION_PARENT
|
||||
|
||||
__all__ = (
|
||||
'CableTable',
|
||||
@@ -28,7 +28,8 @@ class CableTable(NetBoxTable):
|
||||
linkify=True,
|
||||
verbose_name='Rack A'
|
||||
)
|
||||
termination_a = tables.Column(
|
||||
termination_a = tables.TemplateColumn(
|
||||
template_code=CABLE_TERMINATION,
|
||||
accessor=Accessor('termination_a'),
|
||||
orderable=False,
|
||||
linkify=True,
|
||||
@@ -46,7 +47,8 @@ class CableTable(NetBoxTable):
|
||||
linkify=True,
|
||||
verbose_name='Rack B'
|
||||
)
|
||||
termination_b = tables.Column(
|
||||
termination_b = tables.TemplateColumn(
|
||||
template_code=CABLE_TERMINATION,
|
||||
accessor=Accessor('termination_b'),
|
||||
orderable=False,
|
||||
linkify=True,
|
||||
|
@@ -13,14 +13,20 @@ CABLE_LENGTH = """
|
||||
{% if record.length %}{{ record.length|simplify_decimal }} {{ record.length_unit }}{% endif %}
|
||||
"""
|
||||
|
||||
CABLE_TERMINATION = """
|
||||
{{ value|join:", " }}
|
||||
"""
|
||||
|
||||
CABLE_TERMINATION_PARENT = """
|
||||
{% if value.device %}
|
||||
<a href="{{ value.device.get_absolute_url }}">{{ value.device }}</a>
|
||||
{% elif value.circuit %}
|
||||
<a href="{{ value.circuit.get_absolute_url }}">{{ value.circuit }}</a>
|
||||
{% elif value.power_panel %}
|
||||
<a href="{{ value.power_panel.get_absolute_url }}">{{ value.power_panel }}</a>
|
||||
{% endif %}
|
||||
{% with value.0 as termination %}
|
||||
{% if termination.device %}
|
||||
<a href="{{ termination.device.get_absolute_url }}">{{ termination.device }}</a>
|
||||
{% elif termination.circuit %}
|
||||
<a href="{{ termination.circuit.get_absolute_url }}">{{ termination.circuit }}</a>
|
||||
{% elif termination.power_panel %}
|
||||
<a href="{{ termination.power_panel.get_absolute_url }}">{{ termination.power_panel }}</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
"""
|
||||
|
||||
DEVICE_LINK = """
|
||||
|
Reference in New Issue
Block a user