From fff678edd3791f0b1b7ea034bef67efc8fb8b5c8 Mon Sep 17 00:00:00 2001 From: Mark Jordan Date: Tue, 21 May 2024 13:20:09 -0700 Subject: [PATCH] Resolves #783. --- workbench | 7 +++++++ workbench_utils.py | 17 +++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/workbench b/workbench index 7f78ead..18ffcc3 100755 --- a/workbench +++ b/workbench @@ -3108,6 +3108,13 @@ def update_terms(): "'log_term_creation' configuration setting is False. Creation of new taxonomy terms will not be logged." ) + if "term_id" not in csv_column_headers: + message = ( + 'For "update_terms" tasks, your CSV file must contain a "term_id" column.' + ) + logging.error(message) + sys.exit("Error: " + message) + method = "GET" row_count = 0 for row in csv_data: diff --git a/workbench_utils.py b/workbench_utils.py index 164f9e3..c4fa579 100644 --- a/workbench_utils.py +++ b/workbench_utils.py @@ -2714,6 +2714,7 @@ def check_input(config, args): drupal_fieldnames = [] for drupal_fieldname in field_definitions: drupal_fieldnames.append(drupal_fieldname) + """ if "term_name" in csv_column_headers: csv_column_headers.remove("term_name") if "parent" in csv_column_headers: @@ -2724,6 +2725,7 @@ def check_input(config, args): csv_column_headers.remove("description") if "term_id" in csv_column_headers: csv_column_headers.remove("term_id") + """ for csv_column_header in csv_column_headers: if ( @@ -2731,18 +2733,9 @@ def check_input(config, args): and csv_column_header != "term_id" and csv_column_header not in term_base_fields ): - logging.error( - "CSV column header %s does not match any Drupal field names in the %s taxonomy term.", - csv_column_header, - config["vocab_id"], - ) - sys.exit( - 'Error: CSV column header "' - + csv_column_header - + '" does not match any Drupal field names in the ' - + config["vocab_id"] - + " taxonomy term." - ) + message = f'CSV column header "{csv_column_header}" does not match any Drupal field names in the {config["vocab_id"]} vocabulary.' + logging.error(message) + sys.exit("Error: " + message) message = "OK, CSV column headers match Drupal field names." print(message) logging.info(message)