Forráskód Böngészése

Fixes: #17126 - Respect the weight unit of the DeviceType when displaying the Device detail (#17579)

* Respect the weight unit of the DeviceType when displaying the Device details

* Reuse the same weight formatting construct as in rack.html, and add placeholder in rack if empty
bctiemann 1 éve
szülő
commit
cfb5696d29

+ 1 - 0
netbox/templates/dcim/device.html

@@ -325,6 +325,7 @@
                         <td>
                         <td>
                             {% if object.total_weight %}
                             {% if object.total_weight %}
                                 {{ object.total_weight|floatformat }} {% trans "Kilograms" %}
                                 {{ object.total_weight|floatformat }} {% trans "Kilograms" %}
+                                ({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
                             {% else %}
                             {% else %}
                                 {{ ''|placeholder }}
                                 {{ ''|placeholder }}
                             {% endif %}
                             {% endif %}

+ 6 - 2
netbox/templates/dcim/rack.html

@@ -103,8 +103,12 @@
           <tr>
           <tr>
             <th scope="row">{% trans "Total Weight" %}</th>
             <th scope="row">{% trans "Total Weight" %}</th>
             <td>
             <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>
             </td>
           </tr>
           </tr>
         </table>
         </table>