jeremystretch 3 лет назад
Родитель
Сommit
87fd09ca8b

+ 2 - 5
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')),
     )
 

+ 4 - 1
netbox/templates/dcim/rack.html

@@ -171,7 +171,10 @@
                     </tr>
                     <tr>
                         <th scope="row">Total Weight</th>
-                        <td>{{ object.total_weight|floatformat }} Kilograms</td>
+                        <td>
+                          {{ object.total_weight|floatformat }} Kilograms
+                          ({{ object.total_weight|kg_to_pounds|floatformat }} Pounds)
+                        </td>
                     </tr>
                 </table>
             </div>

+ 11 - 8
netbox/templates/dcim/rack_edit.html

@@ -56,17 +56,20 @@
                 <div class="form-text">Unit</div>
             </div>
         </div>
+        <div class="row mb-3">
+            <label class="col col-md-3 col-form-label text-lg-end">Weight</label>
+            <div class="col col-md-6 mb-1">
+                {{ form.weight }}
+                <div class="form-text">Weight</div>
+            </div>
+            <div class="col col-md-3 mb-1">
+                {{ form.weight_unit }}
+                <div class="form-text">Unit</div>
+            </div>
+        </div>
         {% render_field form.mounting_depth %}
         {% render_field form.desc_units %}
     </div>
-    <div class="field-group my-5">
-        <div class="row mb-2">
-          <h5 class="offset-sm-3">Weight</h5>
-        </div>
-        {% render_field form.weight %}
-        {% render_field form.weight_unit %}
-    </div>
-
 
     {% if form.custom_fields %}
       <div class="field-group my-5">

+ 8 - 0
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:
     """