Skip to content

Commit

Permalink
Resolves #783.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed May 21, 2024
1 parent e268f97 commit fff678e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 7 additions & 0 deletions workbench
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 5 additions & 12 deletions workbench_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -2724,25 +2725,17 @@ 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 (
csv_column_header not in drupal_fieldnames
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)
Expand Down

0 comments on commit fff678e

Please sign in to comment.