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

Added length and length_unit fields to Cable

This commit is contained in:
Jeremy Stretch
2018-10-26 10:28:25 -04:00
parent 2d90fc608e
commit 6bea8cc546
9 changed files with 97 additions and 8 deletions

View File

@@ -170,6 +170,10 @@ VIRTUALCHASSIS_ACTIONS = """
{% endif %}
"""
CABLE_LENGTH = """
{% if record.length %}{{ record.length }}{{ record.length_unit }}{% else %}—{% endif %}
"""
#
# Regions
@@ -626,6 +630,10 @@ class CableTable(BaseTable):
args=[Accessor('pk')],
verbose_name='PK'
)
label_ = tables.Column(
accessor=Accessor('label'),
verbose_name='Label'
)
device_a = tables.LinkColumn(
viewname='dcim:device',
accessor=Accessor('termination_a.device'),
@@ -650,10 +658,14 @@ class CableTable(BaseTable):
orderable=False,
verbose_name='Component'
)
length = tables.TemplateColumn(
template_code=CABLE_LENGTH,
order_by='_abs_length'
)
class Meta(BaseTable.Meta):
model = Cable
fields = ('pk', 'device_a', 'termination_a', 'device_b', 'termination_b', 'status', 'type', 'color')
fields = ('pk', 'label_', 'device_a', 'termination_a', 'device_b', 'termination_b', 'status', 'type', 'color')
#