From a0a3e96cdb1581187e1094ea89672da5bd74a8d6 Mon Sep 17 00:00:00 2001 From: PascalRepond Date: Mon, 22 Aug 2022 12:13:11 +0200 Subject: [PATCH] jsonschema: fix partOf subfields display * Closes #626. * Makes the `status` deposit field required to prevent submitting a deposit with no status from the API. Co-Authored-by: Pascal Repond --- .../deposits/jsonschemas/deposits/deposit-v1.0.0_src.json | 7 ++++--- .../jsonschemas/documents/document-v1.0.0_src.json | 4 ++-- tests/ui/users/test_user_jsonresolvers.py | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) 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 bc0e4db2..2e1d9934 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 @@ -4,7 +4,8 @@ "title": "SONAR deposit v1.0.0", "type": "object", "required": [ - "pid" + "pid", + "status" ], "additionalProperties": false, "properties": { @@ -573,7 +574,7 @@ "type": "string", "minLength": 1, "form": { - "hideExpression": "field.parent.parent.model && !['coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.model.documentType)", + "hideExpression": "field.parent.parent.model && !['coar:c_3248', 'coar:c_3e5a', 'coar:c_ba08', coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc', 'coar:c_816b', 'coar:c_5794', 'coar:c_6670', 'coar:c_c94f'].includes(field.parent.parent.model.documentType)", "templateOptions": { "placeholder": "Example: 1, 4-5, …" } @@ -584,7 +585,7 @@ "type": "string", "minLength": 1, "form": { - "hideExpression": "field.parent.parent.model && !['coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.model.documentType)", + "hideExpression": "field.parent.parent.model && !['coar:c_3e5a', 'coar:c_ba08', 'coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc', 'coar:c_816b', 'coar:c_5794', 'coar:c_6670', 'coar:c_c94f'].includes(field.parent.parent.model.documentType)", "templateOptions": { "placeholder": "Example: 10, 22-24, …" } 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 9910b45a..1da8efcc 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 @@ -1581,7 +1581,7 @@ "type": "string", "minLength": 1, "form": { - "hideExpression": "!['coar:c_3e5a', 'coar:c_ba08', coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.parent.model.documentType)" + "hideExpression": "!['coar:c_3248', 'coar:c_3e5a', 'coar:c_ba08', coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc', 'coar:c_816b', 'coar:c_5794', 'coar:c_6670', 'coar:c_c94f'].includes(field.parent.parent.parent.model.documentType)" } }, "numberingIssue": { @@ -1589,7 +1589,7 @@ "type": "string", "minLength": 1, "form": { - "hideExpression": "!['coar:c_3e5a', 'coar:c_ba08', 'coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.parent.parent.model.documentType)" + "hideExpression": "!['coar:c_3e5a', 'coar:c_ba08', 'coar:c_beb9', 'coar:c_6501', 'coar:c_998f', 'coar:c_dcae04bc', 'coar:c_816b', 'coar:c_5794', 'coar:c_6670', 'coar:c_c94f'].includes(field.parent.parent.parent.model.documentType)" } }, "numberingPages": { diff --git a/tests/ui/users/test_user_jsonresolvers.py b/tests/ui/users/test_user_jsonresolvers.py index 8e8a9120..88ae54b9 100644 --- a/tests/ui/users/test_user_jsonresolvers.py +++ b/tests/ui/users/test_user_jsonresolvers.py @@ -37,6 +37,7 @@ def test_user_resolver(app, organisation, roles): record = DepositRecord.create( {'user': { '$ref': 'https://sonar.ch/api/users/1' - }}, with_bucket=False) + }, + 'status': 'in_progress'}, with_bucket=False) assert record.replace_refs().get('user')['email'] == 'admin@test.com'