Closes #10268: Omit trailing ".0" in device positions within UI

This commit is contained in:
jeremystretch 2022-09-07 14:09:17 -04:00
parent 1cbb2320c1
commit b702822857
4 changed files with 13 additions and 6 deletions

View File

@ -2,6 +2,10 @@
## v3.3.3 (FUTURE)
### Enhancements
* [#10268](https://github.com/netbox-community/netbox/issues/10268) - Omit trailing ".0" in device positions within UI
### Bug Fixes
* [#9231](https://github.com/netbox-community/netbox/issues/9231) - Fix `empty` lookup expression for string filters

View File

@ -152,6 +152,9 @@ class DeviceTable(TenancyColumnsMixin, NetBoxTable):
rack = tables.Column(
linkify=True
)
position = columns.TemplateColumn(
template_code='{{ value|floatformat }}'
)
device_role = columns.ColoredLabelColumn(
verbose_name='Role'
)
@ -199,10 +202,10 @@ class DeviceTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Device
fields = (
'pk', 'id', 'name', 'status', 'tenant', 'tenant_group', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial',
'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'airflow', 'primary_ip4',
'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'contacts', 'tags',
'created', 'last_updated',
'pk', 'id', 'name', 'status', 'tenant', 'tenant_group', 'device_role', 'manufacturer', 'device_type',
'platform', 'serial', 'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'airflow',
'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments',
'contacts', 'tags', 'created', 'last_updated',
)
default_columns = (
'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type',

View File

@ -70,7 +70,7 @@
{% endif %}
{% endwith %}
{% elif object.rack and object.position %}
<span>U{{ object.position }} / {{ object.get_face_display }}</span>
<span>U{{ object.position|floatformat }} / {{ object.get_face_display }}</span>
{% elif object.rack and object.device_type.u_height %}
<span class="badge bg-warning">Not racked</span>
{% else %}

View File

@ -55,7 +55,7 @@
<td>{{ device.pk }}</td>
<td>
{% if device.rack %}
{{ device.rack }} / {{ device.position }}
{{ device.rack }} / {{ device.position|floatformat }}
{% else %}
{{ ''|placeholder }}
{% endif %}