Skip to content

Commit 486b2e9

Browse files
phurrelmannPatrick Hurrelmannjeremystretch
authored andcommitted
Fixes: netbox-community#10465 Format all remaining displayed rackunits with floatformat (netbox-community#10481)
* Fixes: netbox-community#10465 Try to finish netbox-community#10268 and format all remaining displayed rackunits with floatformat * netbox-community#10465: PEP8 fix Co-authored-by: Patrick Hurrelmann <[email protected]> Co-authored-by: jeremystretch <[email protected]>
1 parent 46c7a00 commit 486b2e9

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

netbox/dcim/svg/racks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from django.conf import settings
1010
from django.core.exceptions import FieldError
1111
from django.db.models import Q
12+
from django.template.defaultfilters import floatformat
1213
from django.urls import reverse
1314
from django.utils.http import urlencode
1415

@@ -41,7 +42,7 @@ def get_device_description(device):
4142
device.device_role,
4243
device.device_type.manufacturer.name,
4344
device.device_type.model,
44-
device.device_type.u_height,
45+
floatformat(device.device_type.u_height),
4546
device.asset_tag or '',
4647
device.serial or ''
4748
)

netbox/dcim/tables/devicetypes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class DeviceTypeTable(NetBoxTable):
8585
tags = columns.TagColumn(
8686
url_name='dcim:devicetype_list'
8787
)
88+
u_height = columns.TemplateColumn(
89+
template_code='{{ value|floatformat }}'
90+
)
8891

8992
class Meta(NetBoxTable.Meta):
9093
model = DeviceType

netbox/templates/dcim/device.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h5 class="card-header">
6666
{% with object.parent_bay.device as parent %}
6767
{{ parent|linkify }} / {{ object.parent_bay }}
6868
{% if parent.position %}
69-
(U{{ parent.position }} / {{ parent.get_face_display }})
69+
(U{{ parent.position|floatformat }} / {{ parent.get_face_display }})
7070
{% endif %}
7171
{% endwith %}
7272
{% elif object.rack and object.position %}
@@ -90,7 +90,7 @@ <h5 class="card-header">
9090
<tr>
9191
<th scope="row">Device Type</th>
9292
<td>
93-
{{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height }}U)
93+
{{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height|floatformat }}U)
9494
</td>
9595
</tr>
9696
<tr>

netbox/templates/dcim/devicetype.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h5 class="card-header">
2929
</tr>
3030
<tr>
3131
<td>Height (U)</td>
32-
<td>{{ object.u_height }}</td>
32+
<td>{{ object.u_height|floatformat }}</td>
3333
</tr>
3434
<tr>
3535
<td>Full Depth</td>

0 commit comments

Comments
 (0)