Skip to content

Commit

Permalink
Added orcid field to ArticleDocument
Browse files Browse the repository at this point in the history
Utilized the same method used on the legacy article serializer in order to obtain the orcid and add it to the ArticleDocument.
  • Loading branch information
Lorenzovagliano committed Sep 24, 2024
1 parent a58668c commit e417bd7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion scoap3/articles/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django_opensearch_dsl.registries import registry

from scoap3.articles.models import Article, ArticleFile, ArticleIdentifier
from scoap3.authors.models import Author
from scoap3.authors.models import Author, AuthorIdentifierType
from scoap3.misc.models import Affiliation, ArticleArxivCategory, PublicationInfo


Expand Down Expand Up @@ -143,6 +143,19 @@ def prepare_authors(self, instance):
"first_name": author.first_name.strip(),
"last_name": author.last_name.strip(),
"affiliations": serialized_affiliations,
**(
{
"orcid": author.identifiers.filter(
identifier_type=AuthorIdentifierType.ORCID
)
.values_list("identifier_value", flat=True)
.first()
}
if author.identifiers.filter(
identifier_type=AuthorIdentifierType.ORCID
).exists()
else {}
),
}
serialized_authors.append(serialized_author)
return serialized_authors
Expand Down

0 comments on commit e417bd7

Please sign in to comment.