From 37b9f5c88258d87d478d70c2abacde74ff1f9783 Mon Sep 17 00:00:00 2001 From: Ariel Rin Date: Thu, 12 May 2022 13:33:17 +0000 Subject: [PATCH] Merge branch 'fix-decimal_widthratio-template-tag' into 'v3.x' [FIX] Division by zero in decimal_widthratio template tag See merge request allianceauth/allianceauth!1419 (cherry picked from commit 4836559abe800e8d0f5048502b5cdbcd37d14f8b) 8dd07b97 [FIX] Devision by zero in decimal_widthratio template tag 17b06c88 Make it a string in accordance to the return value type --- 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..b673e913 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 str(0) + return str(round(this_value/max_value * max_width, 2))