From 87fd09ca8b5a0d3ec692e241351e1bbc4ac298a7 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 15 Nov 2022 15:30:39 -0500 Subject: [PATCH] Cleanup for #9654 --- netbox/dcim/forms/model_forms.py | 7 ++----- netbox/templates/dcim/rack.html | 5 ++++- netbox/templates/dcim/rack_edit.html | 19 +++++++++++-------- netbox/utilities/templatetags/helpers.py | 8 ++++++++ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index 23498af06..7bfde23eb 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -384,13 +384,10 @@ class DeviceTypeForm(NetBoxModelForm): comments = CommentField() fieldsets = ( - ('Device Type', ( - 'manufacturer', 'model', 'slug', 'description', 'tags', - )), + ('Device Type', ('manufacturer', 'model', 'slug', 'description', 'tags')), ('Chassis', ( - 'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', + 'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit', )), - ('Attributes', ('weight', 'weight_unit')), ('Images', ('front_image', 'rear_image')), ) diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 185634e8a..3c31dc49d 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -171,7 +171,10 @@ Total Weight - {{ object.total_weight|floatformat }} Kilograms + + {{ object.total_weight|floatformat }} Kilograms + ({{ object.total_weight|kg_to_pounds|floatformat }} Pounds) + diff --git a/netbox/templates/dcim/rack_edit.html b/netbox/templates/dcim/rack_edit.html index d214bbee8..1d8dee3ab 100644 --- a/netbox/templates/dcim/rack_edit.html +++ b/netbox/templates/dcim/rack_edit.html @@ -56,17 +56,20 @@
Unit
+
+ +
+ {{ form.weight }} +
Weight
+
+
+ {{ form.weight_unit }} +
Unit
+
+
{% render_field form.mounting_depth %} {% render_field form.desc_units %} -
-
-
Weight
-
- {% render_field form.weight %} - {% render_field form.weight_unit %} -
- {% if form.custom_fields %}
diff --git a/netbox/utilities/templatetags/helpers.py b/netbox/utilities/templatetags/helpers.py index 3b21a2c30..7c5b193fd 100644 --- a/netbox/utilities/templatetags/helpers.py +++ b/netbox/utilities/templatetags/helpers.py @@ -171,6 +171,14 @@ def meters_to_feet(n): return float(n) * 3.28084 +@register.filter() +def kg_to_pounds(n): + """ + Convert a weight from kilograms to pounds. + """ + return float(n) * 2.204623 + + @register.filter("startswith") def startswith(text: str, starts: str) -> bool: """