From 42cadcfd2dfcdf7f07e84083f401d87b4450a609 Mon Sep 17 00:00:00 2001 From: Fatimah Date: Thu, 4 Apr 2024 13:19:19 +0200 Subject: [PATCH] datacite: added access right info --- .../jsonschemas/records/record-v6.0.0.json | 4 ++++ .../resources/serializers/datacite/schema.py | 15 +++++++++++++++ tests/conftest.py | 2 ++ tests/records/full-record.json | 3 ++- .../serializers/test_datacite_serializer.py | 5 +++++ .../resources/serializers/test_dcat_serializer.py | 6 ++++++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/invenio_rdm_records/records/jsonschemas/records/record-v6.0.0.json b/invenio_rdm_records/records/jsonschemas/records/record-v6.0.0.json index 84d02b795c..e8ddd103e1 100644 --- a/invenio_rdm_records/records/jsonschemas/records/record-v6.0.0.json +++ b/invenio_rdm_records/records/jsonschemas/records/record-v6.0.0.json @@ -441,6 +441,10 @@ ] } } + }, + "status": { + "description": "Record access status.", + "type": "string" } } }, diff --git a/invenio_rdm_records/resources/serializers/datacite/schema.py b/invenio_rdm_records/resources/serializers/datacite/schema.py index 9dc5a92841..697798bba0 100644 --- a/invenio_rdm_records/resources/serializers/datacite/schema.py +++ b/invenio_rdm_records/resources/serializers/datacite/schema.py @@ -602,6 +602,21 @@ def get_rights(self, obj): serialized_rights.append(serialized_right) + # Adding access_right information + access_right = obj["access"]["status"] + if access_right == "metadata-only": + access_right = "closed" + + access_right_formatted = access_right.capitalize() + " Access" + rights_uri = "info:eu-repo/semantics/{}Access".format(access_right) + + access_right_serialized = { + "rights": access_right_formatted, + "rightsUri": rights_uri, + } + + serialized_rights.append(access_right_serialized) + return serialized_rights if serialized_rights else missing def get_funding(self, obj): diff --git a/tests/conftest.py b/tests/conftest.py index e6d208451c..7a0e21eec9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -564,6 +564,7 @@ def full_record(users): "until": "2131-01-01", "reason": "Only for medical doctors.", }, + "status": "embargoed", }, "files": { "enabled": True, @@ -846,6 +847,7 @@ def enhanced_full_record(users): "until": "2131-01-01", "reason": "Only for medical doctors.", }, + "status": "embargoed", }, "files": { "enabled": True, diff --git a/tests/records/full-record.json b/tests/records/full-record.json index 71d60abc47..5adcf0daf6 100644 --- a/tests/records/full-record.json +++ b/tests/records/full-record.json @@ -186,7 +186,8 @@ "active": true, "until": "2131-01-01", "reason": "Only for medical doctors." - } + }, + "status": "embargoed" }, "files": { "enabled": true, diff --git a/tests/resources/serializers/test_datacite_serializer.py b/tests/resources/serializers/test_datacite_serializer.py index 454f39fa99..2f3bec76ea 100644 --- a/tests/resources/serializers/test_datacite_serializer.py +++ b/tests/resources/serializers/test_datacite_serializer.py @@ -215,6 +215,10 @@ def test_datacite43_serializer(running_app, full_record): "rightsIdentifier": "cc-by-4.0", "rightsUri": "https://creativecommons.org/licenses/by/4.0/legalcode", }, + { + "rights": "Embargoed Access", + "rightsUri": "info:eu-repo/semantics/embargoedAccess", + }, ], "descriptions": [ { @@ -313,6 +317,7 @@ def test_datacite43_xml_serializer(running_app, full_record): " ", ' A custom license', # noqa ' Creative Commons Attribution 4.0 International', # noqa + ' Embargoed Access', " ", " ", ' A description ', diff --git a/tests/resources/serializers/test_dcat_serializer.py b/tests/resources/serializers/test_dcat_serializer.py index be57fefe80..3150c9e970 100644 --- a/tests/resources/serializers/test_dcat_serializer.py +++ b/tests/resources/serializers/test_dcat_serializer.py @@ -155,6 +155,12 @@ def test_dcat_serializer(running_app, enhanced_full_record): ' ', # noqa " ", " ", + ' ', + " ", + ' ', + " Embargoed Access", + " ", + " ", " ", " ", " ",