Reuse the same weight formatting construct as in rack.html, and add placeholder in rack if empty

This commit is contained in:
Brian Tiemann 2024-09-23 17:45:10 -04:00
parent f769f773f1
commit 0c90284448
2 changed files with 8 additions and 7 deletions

View File

@ -324,11 +324,8 @@
<th scope="row">{% trans "Weight" %}</th>
<td>
{% if object.total_weight %}
{% if object.device_type.weight_unit == "lb" %}
{{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %}
{% elif object.device_type.weight_unit == "kg" %}
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
{% endif %}
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
{% else %}
{{ ''|placeholder }}
{% endif %}

View File

@ -103,8 +103,12 @@
<tr>
<th scope="row">{% trans "Total Weight" %}</th>
<td>
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
{% if object.total_weight %}
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
</tr>
</table>