Skip to content

Commit

Permalink
Merge pull request #1568 from DDMAL/fixed-alt-names-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dchiller authored Jul 18, 2024
2 parents c57b86b + 38ae240 commit 1257e79
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"SK": "Slovakia",
"SA": "South Africa",
"ZA": "South Africa",
"S": "Sweden",
"T": "Taiwan",
"TR": "Turkey",
"US": "United States",
Expand Down Expand Up @@ -161,10 +162,15 @@ def handle(self, *args, **options):
)

institution = created_institutions[siglum]
if institution_name != institution.name:
institution.alternate_names = (
f"{institution.alternate_names}\n{institution_name}"
)

# if the source we're publishing has a different institution name than the
# one that already exists, save the source name as an alternate name.
if institution_name and institution_name != institution.name:
existing_alt_names: list = institution.alternate_names.split("\n") if institution.alternate_names else []
existing_alt_names.append(institution_name.strip())
deduped_names = set(existing_alt_names)
institution.alternate_names = "\n".join(list(deduped_names))

institution.save()
elif siglum not in created_institutions:
print(self.style.SUCCESS(f"Creating institution record for {siglum}"))
Expand Down

0 comments on commit 1257e79

Please sign in to comment.