From 402fabdb16ea90da1797930451b22143d9f8419b Mon Sep 17 00:00:00 2001 From: j Date: Tue, 11 Jun 2019 12:30:18 +0100 Subject: [PATCH] support value map for documenys --- pandora/document/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandora/document/models.py b/pandora/document/models.py index 268302b5..8c58cf11 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -403,6 +403,13 @@ class Document(models.Model): 'rightslevel', ): return getattr(self, key) + document_key = utils.get_by_id(settings.CONFIG['documentKeys'], key) + if document_key and 'value' in document_key \ + and isinstance(document_key['value'], dict) \ + and document_key['value'].get('type') == 'map' \ + and self.get(document_key['value']['key']): + value = re.compile(document_key['value']['map']).findall(self.get_value(document_key['value']['key'])) + return value[0] if value else default elif key == 'user': return self.user.username else: