From bc072f7b7e7f505372038f75310467e01d6db30f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 19 Jun 2019 17:47:32 -0400 Subject: [PATCH] Add column mapping support Add support for specifying metadata columns. Signed-off-by: Roberto Rosario --- .../importer/management/commands/import.py | 62 +++++++++++--- mayan/apps/importer/queues.py | 10 +++ mayan/apps/importer/tasks.py | 85 +++++++++++++++++++ .../tests/test_management_commands.py | 38 ++++++++- 4 files changed, 181 insertions(+), 14 deletions(-) create mode 100644 mayan/apps/importer/queues.py create mode 100644 mayan/apps/importer/tasks.py diff --git a/mayan/apps/importer/management/commands/import.py b/mayan/apps/importer/management/commands/import.py index 3ae3ca0813..ba355444aa 100644 --- a/mayan/apps/importer/management/commands/import.py +++ b/mayan/apps/importer/management/commands/import.py @@ -7,18 +7,34 @@ from django.apps import apps from django.core import management from django.core.files import File -from mayan.apps.documents.tasks import task_upload_new_document +from ...tasks import task_upload_new_document class Command(management.BaseCommand): help = 'Import documents from a CSV file.' def add_arguments(self, parser): - #parser.add_argument( - # '-l', '--link', - # action='store_true', dest='link', default=False, - # help='Create a symbolic link to each file instead of copying.', - #) + parser.add_argument( + '--document_type_column', + action='store', dest='document_type_column', default=0, + help='Column that contains the document type labels. Column ' + 'numbers start at 0.', + type=int + ) + parser.add_argument( + '--document_path_column', + action='store', dest='document_path_column', default=1, + help='Column that contains the path to the document files. Column ' + 'numbers start at 0.', + type=int + ) + parser.add_argument( + '--metadata_pairs_column', + action='store', dest='metadata_pairs_column', + help='Column that contains metadata name and values for the ' + 'documents. Use the form: