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

deposits: improve editor and process #577

Merged
merged 1 commit into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions sonar/common/jsonschemas/language-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,7 @@
],
"form": {
"templateOptions": {
"sort": true,
"wrappers": [
"card"
]
"sort": true
},
"options": [
{
Expand Down
13 changes: 7 additions & 6 deletions sonar/common/jsonschemas/license-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
}
]
}
Expand Down
39 changes: 39 additions & 0 deletions sonar/common/jsonschemas/oa-status-v1.0.0.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
6 changes: 5 additions & 1 deletion sonar/modules/deposits/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down Expand Up @@ -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)
Expand Down
81 changes: 54 additions & 27 deletions sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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]+$",
sebdeleze marked this conversation as resolved.
Show resolved Hide resolved
"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]+$",
sebdeleze marked this conversation as resolved.
Show resolved Hide resolved
"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": {
Expand All @@ -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": {
Expand All @@ -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"
Expand Down Expand Up @@ -715,10 +732,10 @@
}
},
"subjects": {
"title": "Subjects",
"title": "Keywords",
"type": "array",
"items": {
"title": "Subject",
"title": "Keyword",
"type": "object",
"required": [
"language",
Expand All @@ -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
Expand Down Expand Up @@ -900,9 +917,6 @@
"projects": {
"title": "Research projects",
"type": "array",
"default": [
{}
],
"minItems": 0,
"items": {
"title": "Research project",
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -990,6 +1014,9 @@
"properties": {
"license": {
"$ref": "license-v1.0.0.json"
},
"oa_status": {
"$ref": "oa-status-v1.0.0.json"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ def deposit_json():
'2020',
'publication': {
'publishedIn': 'Journal',
'year': '2019',
'volume': '12',
'number': '2',
'pages': '1-12',
Expand Down Expand Up @@ -509,7 +508,8 @@ def deposit_json():
}]
},
'diffusion': {
'license': 'CC0'
'license': 'CC0',
'oa_status': 'green'
},
'status':
'in_progress',
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/deposits/test_deposits_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down