Bläddra i källkod

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

jeremystretch 3 år sedan
förälder
incheckning
b702822857

+ 4 - 0
docs/release-notes/version-3.3.md

@@ -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

+ 7 - 4
netbox/dcim/tables/devices.py

@@ -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',

+ 1 - 1
netbox/templates/dcim/device.html

@@ -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 %}

+ 1 - 1
netbox/templates/dcim/virtualchassis_edit.html

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