Skip to content

Commit

Permalink
Merge pull request #384 from ror-community/api-v2-create
Browse files Browse the repository at this point in the history
Add validation check for name version with null lang code
  • Loading branch information
lizkrznarich authored Apr 1, 2024
2 parents 3300797 + 647d5b6 commit c777623
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rorapi/common/csv_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,13 @@ def update_record_from_csv(csv_data, version):
add_values = actions_values[UPDATE_ACTIONS['ADD']]
for a in add_values:
temp_names_match = [tn for tn in temp_names if (t in tn['types'] and tn['value'] == a['value'] and tn['lang'] == a['lang'])]
temp_names_null_lang_match = [tn for tn in temp_names if (tn['value'] == a['value'] and (tn['lang'] is None and a['lang'] is not None))]
# check if value, lang and type already exist
if temp_names_match:
errors.append("Attempting to add names(s) that already exist: {}".format(a))
if temp_names_match or temp_names_null_lang_match:
if temp_names_match:
errors.append("Attempting to add names that already exists: {}".format(a))
if temp_names_null_lang_match:
errors.append("Attempting to add name with lang code that already exists with no lang code: {}".format(a))
else:
name_vals_match = [tn for tn in temp_names if (tn['value'] == a['value'] and tn['lang'] == a['lang'])]
if name_vals_match:
Expand Down

0 comments on commit c777623

Please sign in to comment.