Skip to content

Commit

Permalink
Fixes: netbox-community#10465 Format all remaining displayed rackunit…
Browse files Browse the repository at this point in the history
…s 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]>
  • Loading branch information
3 people authored and jsenecal committed Sep 27, 2022
1 parent 46c7a00 commit 486b2e9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion netbox/dcim/svg/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.conf import settings
from django.core.exceptions import FieldError
from django.db.models import Q
from django.template.defaultfilters import floatformat
from django.urls import reverse
from django.utils.http import urlencode

Expand Down Expand Up @@ -41,7 +42,7 @@ def get_device_description(device):
device.device_role,
device.device_type.manufacturer.name,
device.device_type.model,
device.device_type.u_height,
floatformat(device.device_type.u_height),
device.asset_tag or '',
device.serial or ''
)
Expand Down
3 changes: 3 additions & 0 deletions netbox/dcim/tables/devicetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class DeviceTypeTable(NetBoxTable):
tags = columns.TagColumn(
url_name='dcim:devicetype_list'
)
u_height = columns.TemplateColumn(
template_code='{{ value|floatformat }}'
)

class Meta(NetBoxTable.Meta):
model = DeviceType
Expand Down
4 changes: 2 additions & 2 deletions netbox/templates/dcim/device.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h5 class="card-header">
{% with object.parent_bay.device as parent %}
{{ parent|linkify }} / {{ object.parent_bay }}
{% if parent.position %}
(U{{ parent.position }} / {{ parent.get_face_display }})
(U{{ parent.position|floatformat }} / {{ parent.get_face_display }})
{% endif %}
{% endwith %}
{% elif object.rack and object.position %}
Expand All @@ -90,7 +90,7 @@ <h5 class="card-header">
<tr>
<th scope="row">Device Type</th>
<td>
{{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height }}U)
{{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height|floatformat }}U)
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/dcim/devicetype.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5 class="card-header">
</tr>
<tr>
<td>Height (U)</td>
<td>{{ object.u_height }}</td>
<td>{{ object.u_height|floatformat }}</td>
</tr>
<tr>
<td>Full Depth</td>
Expand Down

0 comments on commit 486b2e9

Please sign in to comment.