From 846b029f70e2a6e27e30a1df7c8b5c1403fc52be Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Mon, 29 Apr 2024 21:05:43 +0200 Subject: [PATCH] Add: template tag for size_to_human_readable --- .../apps/sites/templatetags/string_helper.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 archivist/apps/sites/templatetags/string_helper.py diff --git a/archivist/apps/sites/templatetags/string_helper.py b/archivist/apps/sites/templatetags/string_helper.py new file mode 100644 index 0000000..92116f8 --- /dev/null +++ b/archivist/apps/sites/templatetags/string_helper.py @@ -0,0 +1,18 @@ +from django import template + +from utils.strings import convert_size + +register = template.Library() + +@register.filter +def size_to_human_readable (size): + """ + A filter that converts the given size to a human-readable format using the utils.strings.convert_size function. + + Parameters: + size: The size to be converted. + + Returns: + The human-readable size format. + """ + return convert_size(size)