Skip to content

Commit

Permalink
fix: create a new work if no siglum is provided
Browse files Browse the repository at this point in the history
get or create based on sigle is not sufficient, so in addition to sigle check we need to create a new work if siglum is empty
  • Loading branch information
babslgam authored and koeaw committed Mar 18, 2024
1 parent 2427819 commit f9f8fb7
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions apis_ontology/scripts/import_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,20 @@ def create_work(title: str, subtitle: str, siglum: str, source: DataSource):
:param source: DataSource object to link to, used to identify data imports
:return: Work object
"""
work, created = Work.objects.get_or_create(
siglum=siglum,
)

if created:
work.title = title
work.subtitle = subtitle
work.data_source = source
work.save()
if siglum:
work, created = Work.objects.get_or_create(
siglum=siglum,
)

if created:
work.title = title
work.subtitle = subtitle
work.data_source = source
work.save()
else:
work = Work.objects.create(title=title, subtitle=subtitle, data_source=source)
created = True

return work, created

Expand Down

0 comments on commit f9f8fb7

Please sign in to comment.