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) ## v3.3.3 (FUTURE)
### Enhancements
* [#10268](https://github.com/netbox-community/netbox/issues/10268) - Omit trailing ".0" in device positions within UI
### Bug Fixes ### Bug Fixes
* [#9231](https://github.com/netbox-community/netbox/issues/9231) - Fix `empty` lookup expression for string filters * [#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( rack = tables.Column(
linkify=True linkify=True
) )
position = columns.TemplateColumn(
template_code='{{ value|floatformat }}'
)
device_role = columns.ColoredLabelColumn( device_role = columns.ColoredLabelColumn(
verbose_name='Role' verbose_name='Role'
) )
@ -199,10 +202,10 @@ class DeviceTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta): class Meta(NetBoxTable.Meta):
model = Device model = Device
fields = ( fields = (
'pk', 'id', 'name', 'status', 'tenant', 'tenant_group', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial', 'pk', 'id', 'name', 'status', 'tenant', 'tenant_group', 'device_role', 'manufacturer', 'device_type',
'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'airflow', 'primary_ip4', 'platform', 'serial', 'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'airflow',
'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'contacts', 'tags', 'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments',
'created', 'last_updated', 'contacts', 'tags', 'created', 'last_updated',
) )
default_columns = ( default_columns = (
'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type', 'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type',

View File

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

View File

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