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

imprint: ui serializer and missing fields #1305

Closed
Closed
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
20 changes: 15 additions & 5 deletions invenio_rdm_records/resources/serializers/ui/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,21 @@ def _format_journal(journal, publication_date):

def _format_imprint(imprint, publisher):
"""Formats a imprint object into a string based on its attributes."""
place = imprint.get("place", "")
isbn = imprint.get("isbn", "")
formatted = "{publisher}{place} {isbn}".format(
publisher=publisher, place=f", {place}", isbn=f"({isbn})"
)
imprint_title = imprint.get("title")
imprint_place = imprint.get("place")
imprint_isbn = imprint.get("isbn")
imprint_pages = imprint.get("pages")
title_page = f"{imprint_title}" if imprint_title else None
if imprint_pages:
if title_page:
title_page += f", {imprint_pages}."
else:
title_page = f"{imprint_pages}."
else:
title_page += "."
place = f"{imprint_place}." if imprint_place else None
isbn = f"ISBN: {imprint_isbn}." if imprint_isbn else None
formatted = " ".join(filter(None, [title_page, place, isbn]))
return formatted

attr = "custom_fields"
Expand Down