diff --git a/sonar/common/jsonschemas/language-v1.0.0.json b/sonar/common/jsonschemas/language-v1.0.0.json index f63f3fc9..31edb869 100644 --- a/sonar/common/jsonschemas/language-v1.0.0.json +++ b/sonar/common/jsonschemas/language-v1.0.0.json @@ -490,10 +490,7 @@ ], "form": { "templateOptions": { - "sort": true, - "wrappers": [ - "card" - ] + "sort": true }, "options": [ { diff --git a/sonar/common/jsonschemas/license-v1.0.0.json b/sonar/common/jsonschemas/license-v1.0.0.json index 1174c824..a03f13fc 100644 --- a/sonar/common/jsonschemas/license-v1.0.0.json +++ b/sonar/common/jsonschemas/license-v1.0.0.json @@ -9,9 +9,10 @@ "CC BY-NC-SA", "CC BY-ND", "CC BY-SA", - "Other OA / license undefined", - "Not OA / Rights reserved" + "License undefined", + "Rights reserved" ], + "default": "License undefined", "form": { "templateOptions": { "wrappers": [ @@ -48,12 +49,12 @@ "value": "CC BY-SA" }, { - "label": "Other OA / license undefined", - "value": "Other OA / license undefined" + "label": "License undefined", + "value": "License undefined" }, { - "label": "Not OA / Rights reserved", - "value": "Not OA / Rights reserved" + "label": "Rights reserved", + "value": "Rights reserved" } ] } diff --git a/sonar/common/jsonschemas/oa-status-v1.0.0.json b/sonar/common/jsonschemas/oa-status-v1.0.0.json new file mode 100644 index 00000000..f6089386 --- /dev/null +++ b/sonar/common/jsonschemas/oa-status-v1.0.0.json @@ -0,0 +1,39 @@ +{ + "title": "Open access status", + "type": "string", + "enum": [ + "green", + "gold", + "hybrid", + "bronze", + "closed" + ], + "form": { + "hide": true, + "navigation": { + "essential": true + }, + "options": [ + { + "label": "Green", + "value": "green" + }, + { + "label": "Gold", + "value": "gold" + }, + { + "label": "Hybrid", + "value": "hybrid" + }, + { + "label": "Bronze", + "value": "bronze" + }, + { + "label": "Closed", + "value": "closed" + } + ] + } +} diff --git a/sonar/modules/deposits/api.py b/sonar/modules/deposits/api.py index 547c586d..a9c068e3 100644 --- a/sonar/modules/deposits/api.py +++ b/sonar/modules/deposits/api.py @@ -187,7 +187,7 @@ def create_document(self): # Published in if self['metadata'].get('publication'): part_of = { - 'numberingYear': self['metadata']['publication']['year'], + 'numberingYear': self['metadata']['documentDate'], 'document': { 'title': self['metadata']['publication']['publishedIn'] } @@ -343,6 +343,10 @@ def create_document(self): 'license': self['diffusion']['license'] } + # Open access status + if self['diffusion'].get('oa_status'): + metadata['oa_status'] = self['diffusion']['oa_status'] + document = DocumentRecord.create(metadata, dbcommit=True, with_bucket=True) diff --git a/sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json b/sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json index fa809dc0..6d300479 100644 --- a/sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json +++ b/sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json @@ -537,16 +537,14 @@ } }, "publication": { - "title": "Part of (host document)", + "title": "Contained in (journal, book, proceedings)", "type": "object", "required": [ - "publishedIn", - "year" + "publishedIn" ], "additionalProperties": false, "propertiesOrder": [ "publishedIn", - "year", "volume", "number", "pages", @@ -560,25 +558,38 @@ "type": "string", "minLength": 1 }, - "year": { - "title": "Year", - "type": "string", - "minLength": 1 - }, "volume": { "title": "Volume", "type": "string", "minLength": 1, + "pattern": "^[0-9]+$", "form": { - "hideExpression": "!['coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.model.documentType)" + "hideExpression": "!['coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.model.documentType)", + "templateOptions": { + "placeholder": "Example: 1" + }, + "validation": { + "messages": { + "patternMessage": "Please enter a valid number." + } + } } }, "number": { "title": "Number", "type": "string", "minLength": 1, + "pattern": "^[0-9]+$", "form": { - "hideExpression": "!['coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.model.documentType)" + "hideExpression": "!['coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.model.documentType)", + "templateOptions": { + "placeholder": "Example: 10" + }, + "validation": { + "messages": { + "patternMessage": "Please enter a valid number." + } + } } }, "pages": { @@ -589,17 +600,23 @@ "form": { "templateOptions": { "placeholder": "Examples: 135, 5-27, …" + }, + "validation": { + "messages": { + "patternMessage": "Please enter a valid pages range, example: 135, 5-27." + } } } }, "editors": { - "title": "Editors", - "description": "In the format \"Last name, First name\". For example, \"Doe, John\"", + "title": "Authors / Editors", "type": "array", "items": { "type": "string", - "minLength": 1, - "pattern": "^[^,]+, [^,]+$" + "minLength": 1 + }, + "form": { + "hideExpression": "['coar:c_6501'].includes(field.parent.parent.model.documentType)" } }, "publisher": { @@ -609,7 +626,7 @@ } }, "form": { - "hideExpression": "!['coar:c_3248', 'coar:c_5794', 'coar:c_6670', 'coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.model.documentType)", + "hideExpression": "!['coar:c_3248', 'coar:c_5794', 'coar:c_6670', 'coar:c_3e5a', 'coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.model.documentType)", "templateOptions": { "wrappers": [ "card" @@ -715,10 +732,10 @@ } }, "subjects": { - "title": "Subjects", + "title": "Keywords", "type": "array", "items": { - "title": "Subject", + "title": "Keyword", "type": "object", "required": [ "language", @@ -734,10 +751,10 @@ "$ref": "language-v1.0.0.json" }, "subjects": { - "title": "Subjects", + "title": "Values", "type": "array", "minItems": 1, - "default": [], + "default": [null], "items": { "type": "string", "minLength": 1 @@ -900,9 +917,6 @@ "projects": { "title": "Research projects", "type": "array", - "default": [ - {} - ], "minItems": 0, "items": { "title": "Research project", @@ -950,17 +964,27 @@ }, "startDate": { "title": "Start date", - "description": "Example: 2019-05-05", "type": "string", "format": "date", - "pattern": "^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$" + "pattern": "^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$", + "form": { + "type": "datepicker", + "templateOptions": { + "placeholder": "Example: 2020-12-01" + } + } }, "endDate": { "title": "End date", - "description": "Example: 2019-05-05", "type": "string", "format": "date", - "pattern": "^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$" + "pattern": "^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$", + "form": { + "type": "datepicker", + "templateOptions": { + "placeholder": "Example: 2020-12-01" + } + } } }, "propertiesOrder": [ @@ -990,6 +1014,9 @@ "properties": { "license": { "$ref": "license-v1.0.0.json" + }, + "oa_status": { + "$ref": "oa-status-v1.0.0.json" } }, "required": [ diff --git a/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json b/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json index 223856c0..17368577 100644 --- a/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json +++ b/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json @@ -1757,43 +1757,7 @@ } }, "oa_status": { - "title": "Open access status", - "type": "string", - "enum": [ - "green", - "gold", - "hybrid", - "bronze", - "closed" - ], - "form": { - "hide": true, - "navigation": { - "essential": true - }, - "options": [ - { - "label": "Green", - "value": "green" - }, - { - "label": "Gold", - "value": "gold" - }, - { - "label": "Hybrid", - "value": "hybrid" - }, - { - "label": "Bronze", - "value": "bronze" - }, - { - "label": "Closed", - "value": "closed" - } - ] - } + "$ref": "oa-status-v1.0.0.json" }, "customField1": { "title": "Custom field 1", diff --git a/tests/conftest.py b/tests/conftest.py index 17b4a440..28f37e2f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -462,7 +462,6 @@ def deposit_json(): '2020', 'publication': { 'publishedIn': 'Journal', - 'year': '2019', 'volume': '12', 'number': '2', 'pages': '1-12', @@ -509,7 +508,8 @@ def deposit_json(): }] }, 'diffusion': { - 'license': 'CC0' + 'license': 'CC0', + 'oa_status': 'green' }, 'status': 'in_progress', diff --git a/tests/ui/deposits/test_deposits_api.py b/tests/ui/deposits/test_deposits_api.py index 70f4a127..0b5302ad 100644 --- a/tests/ui/deposits/test_deposits_api.py +++ b/tests/ui/deposits/test_deposits_api.py @@ -88,7 +88,7 @@ def test_create_document(app, db, project, client, deposit, submitter): }] }] assert document['partOf'] == [{ - 'numberingYear': '2019', + 'numberingYear': '2020', 'numberingPages': '1-12', 'document': { 'title': 'Journal',