From 4a7cb33fade4403fc2fe37bc061d2bcdbd928394 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 19 Nov 2019 23:04:00 +0100 Subject: Fix display history for operation --- ishtar_common/templatetags/ishtar_helpers.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ishtar_common') diff --git a/ishtar_common/templatetags/ishtar_helpers.py b/ishtar_common/templatetags/ishtar_helpers.py index 51f5e722e..282f35521 100644 --- a/ishtar_common/templatetags/ishtar_helpers.py +++ b/ishtar_common/templatetags/ishtar_helpers.py @@ -17,6 +17,22 @@ def and_(value1, value2): return value1 and value2 +@register.filter +def safe_or(item, args): + if not item: + return False + for arg in args.split("|"): + result = True + current_item = item + for sub in arg.split("."): + if not hasattr(current_item, sub) or not getattr(current_item, sub): + result = False + break + current_item = getattr(current_item, sub) + if result: + return True + + @register.filter def file_content(value): if value: -- cgit v1.2.3