From 8dd07b97c7450f46cbd0d0aac505905b5cc7c729 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Thu, 12 May 2022 13:27:26 +0200 Subject: [PATCH 1/2] [FIX] Devision by zero in decimal_widthratio template tag Fixes: #1343 --- allianceauth/templatetags/admin_status.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/allianceauth/templatetags/admin_status.py b/allianceauth/templatetags/admin_status.py index 73ee909b..a8e92594 100644 --- a/allianceauth/templatetags/admin_status.py +++ b/allianceauth/templatetags/admin_status.py @@ -38,6 +38,9 @@ logger = logging.getLogger(__name__) @register.simple_tag() def decimal_widthratio(this_value, max_value, max_width) -> str: + if max_value == 0: + return 0 + return str(round(this_value/max_value * max_width, 2)) From 17b06c884552f219f15e590edceb1b36b91d2936 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Thu, 12 May 2022 13:31:06 +0200 Subject: [PATCH 2/2] Make it a string in accordance to the return value type --- allianceauth/templatetags/admin_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allianceauth/templatetags/admin_status.py b/allianceauth/templatetags/admin_status.py index a8e92594..b673e913 100644 --- a/allianceauth/templatetags/admin_status.py +++ b/allianceauth/templatetags/admin_status.py @@ -39,7 +39,7 @@ logger = logging.getLogger(__name__) @register.simple_tag() def decimal_widthratio(this_value, max_value, max_width) -> str: if max_value == 0: - return 0 + return str(0) return str(round(this_value/max_value * max_width, 2))