From 860c39944f992efa7675485bd81bee1953d555ad Mon Sep 17 00:00:00 2001 From: Saria Hajjar Date: Thu, 20 Feb 2020 21:26:53 +0000 Subject: [PATCH] Handle divide by zero power stats with very low values --- netbox/templates/dcim/device.html | 15 ++++++++++----- netbox/templates/dcim/powerfeed.html | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 8c457121f..ffa6d89f9 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -393,11 +393,16 @@ Leg {{ leg.name }} {{ leg.outlet_count }} - {{ leg.allocated }} - {{ powerfeed.available_power|divide:3 }}VA - {% with phase_available=powerfeed.available_power|divide:3 %} - {% utilization_graph leg.allocated|percentage:phase_available %} - {% endwith %} + {{ leg.allocated }}VA + {% if powerfeed.available_power %} + {{ powerfeed.available_power|divide:3 }}VA + {% with phase_available=powerfeed.available_power|divide:3 %} + {% utilization_graph leg.allocated|percentage:phase_available %} + {% endwith %} + {% else %} + — + — + {% endif %} {% endfor %} {% endwith %} diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index 316e0e5f0..96703792b 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -110,7 +110,7 @@ {% if utilization %} {{ utilization.allocated }}VA / {{ powerfeed.available_power }}VA - {% if powerfeed.available_power > 0 %} + {% if powerfeed.available_power %} {% utilization_graph utilization.allocated|percentage:powerfeed.available_power %} {% endif %}