forked from 0x2620/pandora
add format option to map
This commit is contained in:
parent
484e052627
commit
e260950c88
2 changed files with 4 additions and 0 deletions
|
@ -412,6 +412,8 @@ class Document(models.Model, FulltextMixin):
|
||||||
and document_key['value'].get('type') == 'map' \
|
and document_key['value'].get('type') == 'map' \
|
||||||
and self.get_value(document_key['value']['key']):
|
and self.get_value(document_key['value']['key']):
|
||||||
value = re.compile(document_key['value']['map']).findall(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
|
return value[0] if value else default
|
||||||
elif key == 'user':
|
elif key == 'user':
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
|
|
@ -215,6 +215,8 @@ class Item(models.Model):
|
||||||
and item_key['value'].get('type') == 'map' \
|
and item_key['value'].get('type') == 'map' \
|
||||||
and self.get(item_key['value']['key']):
|
and self.get(item_key['value']['key']):
|
||||||
value = re.compile(item_key['value']['map']).findall(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 value[0] if value else default
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue