Skip to content

Commit

Permalink
Cleanup for #9654
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Nov 15, 2022
1 parent 0bcc59a commit 87fd09c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
7 changes: 2 additions & 5 deletions netbox/dcim/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
)

Expand Down
5 changes: 4 additions & 1 deletion netbox/templates/dcim/rack.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ <h5 class="card-header">Dimensions</h5>
</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>
Expand Down
19 changes: 11 additions & 8 deletions netbox/templates/dcim/rack_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ <h5 class="offset-sm-3">Dimensions</h5>
<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">
Expand Down
8 changes: 8 additions & 0 deletions netbox/utilities/templatetags/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down

0 comments on commit 87fd09c

Please sign in to comment.