Add support for including a metadata dictionary as an attachment for the POP3 and IMAP sources.
This commit is contained in:
@@ -119,3 +119,18 @@ def convert_dict_to_dict_list(dictionary):
|
||||
result.append({'id': metadata_type.pk, 'value': value})
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def set_bulk_metadata(document, metadata_dictionary):
|
||||
document_type = document.document_type
|
||||
document_type_metadata_types = [
|
||||
document_type_metadata_type.metadata_type for document_type_metadata_type in document_type.metadata.all()
|
||||
]
|
||||
|
||||
for metadata_type_name, value in metadata_dictionary.items():
|
||||
metadata_type = MetadataType.objects.get(name=metadata_type_name)
|
||||
|
||||
if metadata_type in document_type_metadata_types:
|
||||
DocumentMetadata.objects.get_or_create(
|
||||
document=document, metadata_type=metadata_type, value=value
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user