Add the options --metadata and --document_type to the bulk uploader

This commit is contained in:
Roberto Rosario
2012-01-26 11:14:22 -04:00
parent fd19f4502c
commit 850c6dd69a
3 changed files with 56 additions and 12 deletions
+12
View File
@@ -107,3 +107,15 @@ def get_metadata_string(document):
Return a formated representation of a document's metadata values
"""
return u', '.join([u'%s - %s' % (metadata.metadata_type, metadata.value) for metadata in DocumentMetadata.objects.filter(document=document).select_related('metadata_type')])
def convert_dict_to_dict_list(dictionary):
result = []
for key, value in dictionary.items():
try:
metadata_type = MetadataType.objects.get(name=key)
except MetadataType.DoesNotExist:
raise ValueError('Unknown metadata type name')
result.append({'id': metadata_type.pk, 'value': value})
return result