diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py
index 5572f1626..1aa5a7281 100644
--- a/netbox/circuits/models.py
+++ b/netbox/circuits/models.py
@@ -264,7 +264,7 @@ class CircuitTermination(CableTermination):
unique_together = ['circuit', 'term_side']
def __str__(self):
- return '{} (Side {})'.format(self.circuit, self.get_term_side_display())
+ return 'Side {}'.format(self.get_term_side_display())
def log_change(self, user, request_id, action):
"""
diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py
index 6c4dc6f2d..20dc4b52c 100644
--- a/netbox/dcim/api/views.py
+++ b/netbox/dcim/api/views.py
@@ -498,7 +498,9 @@ class InterfaceConnectionViewSet(ModelViewSet):
#
class CableViewSet(ModelViewSet):
- queryset = Cable.objects.prefetch_related('termination_a__device', 'termination_b__device')
+ queryset = Cable.objects.prefetch_related(
+ 'termination_a', 'termination_b'
+ )
serializer_class = serializers.CableSerializer
filter_class = filters.CableFilter
diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py
index 3ffaded78..e0acab111 100644
--- a/netbox/dcim/tables.py
+++ b/netbox/dcim/tables.py
@@ -170,6 +170,14 @@ VIRTUALCHASSIS_ACTIONS = """
{% endif %}
"""
+CABLE_TERMINATION_PARENT = """
+{% if value.device %}
+ {{ value.device }}
+{% else %}
+ {{ value.circuit }}
+{% endif %}
+"""
+
CABLE_LENGTH = """
{% if record.length %}{{ record.length }}{{ record.length_unit }}{% else %}—{% endif %}
"""
@@ -632,29 +640,27 @@ class CableTable(BaseTable):
accessor=Accessor('label'),
verbose_name='Label'
)
- device_a = tables.LinkColumn(
- viewname='dcim:device',
- accessor=Accessor('termination_a.device'),
- args=[Accessor('termination_a.device.pk')],
+ termination_a_parent = tables.TemplateColumn(
+ template_code=CABLE_TERMINATION_PARENT,
+ accessor=Accessor('termination_a'),
orderable=False,
- verbose_name='Device A'
+ verbose_name='Termination A'
)
termination_a = tables.Column(
- accessor=Accessor('termination_a.name'),
+ accessor=Accessor('termination_a'),
orderable=False,
- verbose_name='Component'
+ verbose_name=''
)
- device_b = tables.LinkColumn(
- viewname='dcim:device',
- accessor=Accessor('termination_b.device'),
- args=[Accessor('termination_b.device.pk')],
+ termination_b_parent = tables.TemplateColumn(
+ template_code=CABLE_TERMINATION_PARENT,
+ accessor=Accessor('termination_b'),
orderable=False,
- verbose_name='Device B'
+ verbose_name='Termination B'
)
termination_b = tables.Column(
- accessor=Accessor('termination_b.name'),
+ accessor=Accessor('termination_b'),
orderable=False,
- verbose_name='Component'
+ verbose_name=''
)
length = tables.TemplateColumn(
template_code=CABLE_LENGTH,
@@ -665,7 +671,8 @@ class CableTable(BaseTable):
class Meta(BaseTable.Meta):
model = Cable
fields = (
- 'pk', 'id', 'label_', 'device_a', 'termination_a', 'device_b', 'termination_b', 'status', 'type', 'color',
+ 'pk', 'id', 'label_', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b',
+ 'status', 'type', 'color', 'length',
)
diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
index 9f27f2e72..7be086229 100644
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -1612,7 +1612,7 @@ class DeviceBulkAddDeviceBayView(PermissionRequiredMixin, BulkComponentCreateVie
class CableListView(ObjectListView):
queryset = Cable.objects.prefetch_related(
- 'termination_a__device', 'termination_b__device'
+ 'termination_a', 'termination_b'
)
filter = filters.CableFilter
filter_form = forms.CableFilterForm