From b58f74a929c95bf1f4d74d009c4da91f7f115d53 Mon Sep 17 00:00:00 2001 From: mrbokster Date: Mon, 13 Nov 2023 20:59:42 +0100 Subject: [PATCH 1/2] Bugfix for filter listing when items is null --- resources/lib/criterion_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lib/criterion_parser.py b/resources/lib/criterion_parser.py index dd4a2ab..75c9d4f 100644 --- a/resources/lib/criterion_parser.py +++ b/resources/lib/criterion_parser.py @@ -20,7 +20,7 @@ def parse_criterion(criterion): value = criterion.get('value', '') if isinstance(value, dict) and 'depth' in value: - if 'items' in value: + if 'items' in value and value['items'] is not None: filter['value'] = list(map(lambda v: v['id'], value['items'])) if 'excluded' in value: @@ -31,7 +31,7 @@ def parse_criterion(criterion): filter.update(value) elif isinstance(value, list): filter['value'] = list(map(lambda v: v['id'], value)) - else: + elif value is not '': filter['value'] = value return filter From 179bbf73667e06c75e2b8e2847c70dd59da28f10 Mon Sep 17 00:00:00 2001 From: gitgiggety Date: Tue, 14 Nov 2023 16:58:04 +0100 Subject: [PATCH 2/2] fix criterions once more * Fix handling of both missing and null/None values for includes / excludes * Handle criterions without values --- resources/lib/criterion_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/lib/criterion_parser.py b/resources/lib/criterion_parser.py index 75c9d4f..b697b04 100644 --- a/resources/lib/criterion_parser.py +++ b/resources/lib/criterion_parser.py @@ -20,10 +20,10 @@ def parse_criterion(criterion): value = criterion.get('value', '') if isinstance(value, dict) and 'depth' in value: - if 'items' in value and value['items'] is not None: + if value.get('items') is not None: filter['value'] = list(map(lambda v: v['id'], value['items'])) - if 'excluded' in value: + if value.get('excluded') is not None: filter['excludes'] = list(map(lambda v: v['id'], value['excluded'])) filter['depth'] = value['depth'] @@ -31,7 +31,7 @@ def parse_criterion(criterion): filter.update(value) elif isinstance(value, list): filter['value'] = list(map(lambda v: v['id'], value)) - elif value is not '': + elif 'value' in criterion: filter['value'] = value return filter