Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openaire: added award title and acronym to serialization. #704

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/zenodo_rdm/openaire/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def __init__(self, **options):
format_serializer_cls=JSONSerializer,
object_schema_cls=OpenAIRESchema,
list_schema_cls=BaseListSchema,
**options
**options,
)
16 changes: 10 additions & 6 deletions site/zenodo_rdm/openaire/serializers/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# it under the terms of the MIT License; see LICENSE file for more details.
"""OpenAire schema."""

from urllib.parse import quote_plus

from invenio_access.permissions import system_identity
from invenio_communities.proxies import current_communities
from marshmallow import Schema, fields, missing, pre_dump
Expand Down Expand Up @@ -193,13 +195,15 @@ def _reverse_funder_acronym(funder_ror):
funder = grant.get("funder", {})
if funder and award:
funder_ror = funder.get("id")
funder_acronym = _reverse_funder_acronym(funder_ror)
award_program = award.get("program", "")
award_number = award.get("number", "")
# url-encode the fields
funder_acronym = quote_plus(_reverse_funder_acronym(funder_ror))
award_program = quote_plus(award.get("program", ""))
award_number = quote_plus(award.get("number", ""))
award_title = quote_plus(award.get("title", {}).get("en", ""))
award_acronym = quote_plus(award.get("acronym", ""))
if funder_acronym and award_program and award_number:
links.append(
f"info:eu-repo/grantAgreement/{funder_acronym}/{award_program}/{award_number}"
)
b_link = f"info:eu-repo/grantAgreement/{funder_acronym}/{award_program}/{award_number}{award_title}{award_acronym}"
links.append(b_link)
return links or missing

def get_pids(self, obj):
Expand Down
Loading