From cd9e09774835218938a6cab98ab4bf5650d1223e Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Thu, 5 Dec 2024 09:28:08 -0300 Subject: [PATCH] records: include icon-disclaimer fields in awards --- .../base/services/schemas/funding.py | 31 +++++++++++++++++++ .../base/services/schemas/metadata.py | 3 ++ .../geordmpackages-records-record-v1.0.0.json | 6 ++++ .../geordmpackages/drafts/draft-v1.0.0.json | 6 ++++ .../geordmpackages/records/record-v1.0.0.json | 6 ++++ .../geordmrecords-records-record-v1.0.0.json | 6 ++++ .../geordmrecords/drafts/draft-v1.0.0.json | 6 ++++ .../geordmrecords/records/record-v1.0.0.json | 4 +-- 8 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 geo_rdm_records/base/services/schemas/funding.py diff --git a/geo_rdm_records/base/services/schemas/funding.py b/geo_rdm_records/base/services/schemas/funding.py new file mode 100644 index 0000000..6101716 --- /dev/null +++ b/geo_rdm_records/base/services/schemas/funding.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2022 Geo Secretariat. +# +# geo-rdm-records is free software; you can redistribute it and/or modify it +# under the terms of the MIT License; see LICENSE file for more details. + +"""GEO RDM Records Funding schema definition.""" + +from invenio_rdm_records.services.schemas.metadata import ( + FundingSchema as BaseFundingSchema, +) +from invenio_vocabularies.contrib.awards.schema import ( + AwardRelationSchema as BaseAwardRelationSchema, +) +from marshmallow import fields +from marshmallow_utils.fields import SanitizedUnicode + + +class AwardRelationSchema(BaseAwardRelationSchema): + """Award schema with support to icon and disclaimer.""" + + # ToDo: Review this to limit use for specific cases (e.g., EU projects) + icon = SanitizedUnicode(required=False) + disclaimer = SanitizedUnicode(required=False) + + +class FundingSchema(BaseFundingSchema): + """Funding schema.""" + + award = fields.Nested(AwardRelationSchema) diff --git a/geo_rdm_records/base/services/schemas/metadata.py b/geo_rdm_records/base/services/schemas/metadata.py index 208d365..f861cf2 100644 --- a/geo_rdm_records/base/services/schemas/metadata.py +++ b/geo_rdm_records/base/services/schemas/metadata.py @@ -25,6 +25,7 @@ from marshmallow import fields, validate from marshmallow_utils.fields import SanitizedHTML, SanitizedUnicode +from .funding import FundingSchema from .location import FeatureSchema @@ -76,6 +77,8 @@ class MetadataSchema(BaseMetadataSchema): dump_default={"id": "knowledge", "title": {"en": "Knowledge Package"}}, ) + funding = fields.List(fields.Nested(FundingSchema)) + # # Locations # diff --git a/geo_rdm_records/modules/packages/records/jsonschemas/packages/geordmpackages-records-record-v1.0.0.json b/geo_rdm_records/modules/packages/records/jsonschemas/packages/geordmpackages-records-record-v1.0.0.json index c00a198..5e94a42 100644 --- a/geo_rdm_records/modules/packages/records/jsonschemas/packages/geordmpackages-records-record-v1.0.0.json +++ b/geo_rdm_records/modules/packages/records/jsonschemas/packages/geordmpackages-records-record-v1.0.0.json @@ -339,6 +339,12 @@ "items": { "$ref": "local://definitions-v1.0.0.json#/identifiers_with_scheme" } + }, + "icon": { + "type": "string" + }, + "disclaimer": { + "type": "string" } } } diff --git a/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/drafts/draft-v1.0.0.json b/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/drafts/draft-v1.0.0.json index 8e69d8d..9e6fa79 100644 --- a/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/drafts/draft-v1.0.0.json +++ b/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/drafts/draft-v1.0.0.json @@ -657,6 +657,12 @@ "type": "keyword" } } + }, + "icon": { + "type": "text" + }, + "disclaimer": { + "type": "text" } } }, diff --git a/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/records/record-v1.0.0.json b/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/records/record-v1.0.0.json index f8d113a..f22a88d 100644 --- a/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/records/record-v1.0.0.json +++ b/geo_rdm_records/modules/packages/records/mappings/os-v2/geordmpackages/records/record-v1.0.0.json @@ -613,6 +613,12 @@ "type": "keyword" } } + }, + "icon": { + "type": "text" + }, + "disclaimer": { + "type": "text" } } }, diff --git a/geo_rdm_records/modules/rdm/records/jsonschemas/records/geordmrecords-records-record-v1.0.0.json b/geo_rdm_records/modules/rdm/records/jsonschemas/records/geordmrecords-records-record-v1.0.0.json index 3b6a750..e0edc99 100644 --- a/geo_rdm_records/modules/rdm/records/jsonschemas/records/geordmrecords-records-record-v1.0.0.json +++ b/geo_rdm_records/modules/rdm/records/jsonschemas/records/geordmrecords-records-record-v1.0.0.json @@ -341,6 +341,12 @@ "items": { "$ref": "local://definitions-v1.0.0.json#/identifiers_with_scheme" } + }, + "icon": { + "type": "string" + }, + "disclaimer": { + "type": "string" } } } diff --git a/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/drafts/draft-v1.0.0.json b/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/drafts/draft-v1.0.0.json index cb9183e..8ea7642 100644 --- a/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/drafts/draft-v1.0.0.json +++ b/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/drafts/draft-v1.0.0.json @@ -607,6 +607,12 @@ "type": "keyword" } } + }, + "icon": { + "type": "text" + }, + "disclaimer": { + "type": "text" } } }, diff --git a/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/records/record-v1.0.0.json b/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/records/record-v1.0.0.json index 3cfb668..c612601 100644 --- a/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/records/record-v1.0.0.json +++ b/geo_rdm_records/modules/rdm/records/mappings/os-v2/geordmrecords/records/record-v1.0.0.json @@ -571,8 +571,8 @@ } } }, - "type": { - "type": "keyword" + "icon": { + "type": "text" }, "disclaimer": { "type": "text"