From e260950c88c0bdeb260bf55a2811d006352d20ae Mon Sep 17 00:00:00 2001 From: j Date: Thu, 5 Dec 2019 16:41:03 +0000 Subject: [PATCH] add format option to map --- pandora/document/models.py | 2 ++ pandora/item/models.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pandora/document/models.py b/pandora/document/models.py index 56f46600b..6f6466f03 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -412,6 +412,8 @@ class Document(models.Model, FulltextMixin): and document_key['value'].get('type') == 'map' \ and self.get_value(document_key['value']['key']): value = re.compile(document_key['value']['map']).findall(self.get_value(document_key['value']['key'])) + if value and document_key['value'].get('format'): + value = [document_key['value']['format'].format(value[0])] return value[0] if value else default elif key == 'user': return self.user.username diff --git a/pandora/item/models.py b/pandora/item/models.py index ba98cb1e5..695558c3c 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -215,6 +215,8 @@ class Item(models.Model): and item_key['value'].get('type') == 'map' \ and self.get(item_key['value']['key']): value = re.compile(item_key['value']['map']).findall(self.get(item_key['value']['key'])) + if value and item_key['value'].get('format'): + value = [item_key['value']['format'].format(value[0])] return value[0] if value else default return default