mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Fixed cable list display for circuit terminations
This commit is contained in:
parent
1119209fa0
commit
623de7d210
@ -264,7 +264,7 @@ class CircuitTermination(CableTermination):
|
|||||||
unique_together = ['circuit', 'term_side']
|
unique_together = ['circuit', 'term_side']
|
||||||
|
|
||||||
def __str__(self):
|
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):
|
def log_change(self, user, request_id, action):
|
||||||
"""
|
"""
|
||||||
|
@ -498,7 +498,9 @@ class InterfaceConnectionViewSet(ModelViewSet):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class CableViewSet(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
|
serializer_class = serializers.CableSerializer
|
||||||
filter_class = filters.CableFilter
|
filter_class = filters.CableFilter
|
||||||
|
|
||||||
|
@ -170,6 +170,14 @@ VIRTUALCHASSIS_ACTIONS = """
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
CABLE_TERMINATION_PARENT = """
|
||||||
|
{% if value.device %}
|
||||||
|
<a href="{{ value.device.get_absolute_url }}">{{ value.device }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ value.circuit.get_absolute_url }}">{{ value.circuit }}</a>
|
||||||
|
{% endif %}
|
||||||
|
"""
|
||||||
|
|
||||||
CABLE_LENGTH = """
|
CABLE_LENGTH = """
|
||||||
{% if record.length %}{{ record.length }}{{ record.length_unit }}{% else %}—{% endif %}
|
{% if record.length %}{{ record.length }}{{ record.length_unit }}{% else %}—{% endif %}
|
||||||
"""
|
"""
|
||||||
@ -632,29 +640,27 @@ class CableTable(BaseTable):
|
|||||||
accessor=Accessor('label'),
|
accessor=Accessor('label'),
|
||||||
verbose_name='Label'
|
verbose_name='Label'
|
||||||
)
|
)
|
||||||
device_a = tables.LinkColumn(
|
termination_a_parent = tables.TemplateColumn(
|
||||||
viewname='dcim:device',
|
template_code=CABLE_TERMINATION_PARENT,
|
||||||
accessor=Accessor('termination_a.device'),
|
accessor=Accessor('termination_a'),
|
||||||
args=[Accessor('termination_a.device.pk')],
|
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name='Device A'
|
verbose_name='Termination A'
|
||||||
)
|
)
|
||||||
termination_a = tables.Column(
|
termination_a = tables.Column(
|
||||||
accessor=Accessor('termination_a.name'),
|
accessor=Accessor('termination_a'),
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name='Component'
|
verbose_name=''
|
||||||
)
|
)
|
||||||
device_b = tables.LinkColumn(
|
termination_b_parent = tables.TemplateColumn(
|
||||||
viewname='dcim:device',
|
template_code=CABLE_TERMINATION_PARENT,
|
||||||
accessor=Accessor('termination_b.device'),
|
accessor=Accessor('termination_b'),
|
||||||
args=[Accessor('termination_b.device.pk')],
|
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name='Device B'
|
verbose_name='Termination B'
|
||||||
)
|
)
|
||||||
termination_b = tables.Column(
|
termination_b = tables.Column(
|
||||||
accessor=Accessor('termination_b.name'),
|
accessor=Accessor('termination_b'),
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name='Component'
|
verbose_name=''
|
||||||
)
|
)
|
||||||
length = tables.TemplateColumn(
|
length = tables.TemplateColumn(
|
||||||
template_code=CABLE_LENGTH,
|
template_code=CABLE_LENGTH,
|
||||||
@ -665,7 +671,8 @@ class CableTable(BaseTable):
|
|||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = Cable
|
model = Cable
|
||||||
fields = (
|
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',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1612,7 +1612,7 @@ class DeviceBulkAddDeviceBayView(PermissionRequiredMixin, BulkComponentCreateVie
|
|||||||
|
|
||||||
class CableListView(ObjectListView):
|
class CableListView(ObjectListView):
|
||||||
queryset = Cable.objects.prefetch_related(
|
queryset = Cable.objects.prefetch_related(
|
||||||
'termination_a__device', 'termination_b__device'
|
'termination_a', 'termination_b'
|
||||||
)
|
)
|
||||||
filter = filters.CableFilter
|
filter = filters.CableFilter
|
||||||
filter_form = forms.CableFilterForm
|
filter_form = forms.CableFilterForm
|
||||||
|
Loading…
Reference in New Issue
Block a user