Add support for including a metadata dictionary as an attachment for the POP3 and IMAP sources.

This commit is contained in:
Roberto Rosario
2015-08-13 03:05:55 -04:00
parent 5bb8f779b3
commit 28c45bf988
5 changed files with 82 additions and 17 deletions
+15
View File
@@ -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
)