This commit is contained in:
jeremystretch 2022-11-15 15:30:39 -05:00
parent 0bcc59a1e9
commit 87fd09ca8b
4 changed files with 25 additions and 14 deletions

View File

@ -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')),
)

View File

@ -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>

View File

@ -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">

View File

@ -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:
"""