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

bug: use Accept header to return other formats #2948

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions invenio_app_rdm/records_ui/views/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from invenio_rdm_records.records.systemfields.access.access_settings import (
AccessSettings,
)
from invenio_rdm_records.resources.config import record_serializers
from invenio_rdm_records.resources.serializers import UIJSONSerializer
from invenio_stats.proxies import current_stats
from invenio_users_resources.proxies import current_user_resources
Expand Down Expand Up @@ -146,6 +147,12 @@ def record_detail(
pid_value, record, files, media_files, is_preview=False, include_deleted=False
):
"""Record detail page (aka landing page)."""
if not request.accept_mimetypes.accept_html:
accept_mimetype = request.accept_mimetypes.best_match(record_serializers.keys())
if accept_mimetype:
serializer = record_serializers[accept_mimetype]
return serializer.serializer.serialize_object(record.to_dict())

files_dict = None if files is None else files.to_dict()
media_files_dict = None if media_files is None else media_files.to_dict()

Expand Down