Skip to content

Commit

Permalink
Added condition for importing records from legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestaP committed Feb 22, 2024
1 parent adabf6d commit 00502d2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scoap3/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@ def _create_article(data, licenses):
"subtitle": data["titles"][0].get("subtitle", ""),
"abstract": data["abstracts"][0].get("value", ""),
}
doi = data.get("dois")[0].get("value")
if (
doi
article_data.get("id")
and Article.objects.filter(pk=article_data["id"]).exists()
):
article = Article.objects.get(pk=article_data["id"])
article.__dict__.update(**article_data)
elif (
data.get("dois")[0].get("value")
and ArticleIdentifier.objects.filter(
identifier_type="DOI", identifier_value=doi
identifier_type="DOI", identifier_value=data.get("dois")[0].get("value")
).exists()
):
article = ArticleIdentifier.objects.get(
identifier_type="DOI", identifier_value=doi
identifier_type="DOI", identifier_value=data.get("dois")[0].get("value")
).article_id
article.__dict__.update(**article_data)
else:
Expand Down

0 comments on commit 00502d2

Please sign in to comment.