We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Modify the function update_draft in invenio_drafts_resources/resources/records/resource with the following code snippet:
update_draft
invenio_drafts_resources/resources/records/resource
item_dict = item.to_dict() if "errors" not in item_dict: item_dict["errors"] = [] if not any(error["field"] == "metadata.creators" for error in item_dict["errors"]): item_dict["errors"].append({ "field": "metadata.creators", "messages": ["Missing ORCID or ROR identifier for one or more creators."], "severity": "warning" }) item_dict["errors"].append({ "field": "metadata.creators.0.person_or_org.identifiers", # TODO: Support 2nd message: , "Another warning message." "messages": ["Missing ORCID or ROR identifier."], "severity": "warning" }) item_dict["errors"].append({ "field": "metadata.creators.0.person_or_org.identifiers.0.scheme", "messages": ["No valid scheme recognized for identifier."], }) if not any(error["field"] == "files.enabled" for error in item_dict["errors"]): item_dict["errors"].append({ "field": "files.enabled", "messages": ["Wrong format for uploaded files."], "severity": "warning" }) item_dict["errors"].append({ "field": "metadata.funding", "messages": ["Specific funding required."], "severity": "warning" }) item_dict["errors"].append({ "field": "metadata.references.0.reference", "messages": ["This reference is invalid."], }) item_dict["errors"].append({ "field": "metadata.rights", "messages": ["Specific license required."], "severity": "warning" }) item_dict["errors"].append({ "field": "metadata.version", "messages": ["Specific version required."], "severity": "warning" }) return item_dict, 200
Other version just for creators and funding, with a smarter validation logic:
item_dict = item.to_dict() errors = [] for idx, creator in enumerate(item_dict["metadata"].get("creators", [])): if not creator["person_or_org"].get("identifiers"): errors.append({ "field": f"metadata.creators.{idx}.person_or_org.identifiers", # TODO: Support 2nd message: , "Another warning message." "messages": ["Missing ORCID or ROR identifier."], "severity": "warning" }) funding_ok = False for funding in item_dict["metadata"].get("funding", []): if funding.get("funder", {}).get("id") == "00k4n6c32": funding_ok = True break if not funding_ok: errors.append({ "field": "metadata.funding", "messages": ["Missing EC funding."], "severity": "error" }) if item_dict["metadata"].get("resource_type", {}).get("id") == "publication-article": if not item_dict.get("custom_fields", {}).get("journal:journal", {}).get("title"): errors.append({ "field": "custom_fields.journal:journal.title", "messages": ["Journal title required for publication type journal article."], "severity": "error" }) if not item_dict["metadata"].get("rights"): errors.append({ "field": "metadata.rights", "messages": ["Record must be linked to a license."], "severity": "error" }) else: # Journal article is not CC-BY. # Book/book section is not CY-BY, CC-BY-NC or CC-BY-ND. # Any other resource type is not an CC-BY, CC0 or OSI approved license. if item_dict["metadata"].get("resource_type", {}).get("id") == "publication-article": errors.append({ "field": "metadata.rights", "messages": ["Journal article should use CC-BY."], "severity": "info" }) if item_dict["metadata"].get("resource_type", {}).get("id") == "publication-article": if item_dict.get("access", {}).get("files") == "restricted": errors.append({ "field": "access.files", "messages": ["Visibility should be public for journal article."], "severity": "info" }) if errors: if "errors" not in item_dict: item_dict["errors"] = [] item_dict["errors"].extend(errors) return item_dict, 200
The text was updated successfully, but these errors were encountered:
ptamarit
Successfully merging a pull request may close this issue.
Modify the API to show warnings on files and creators
Modify the function
update_draft
ininvenio_drafts_resources/resources/records/resource
with the following code snippet:Other version just for creators and funding, with a smarter validation logic:
The text was updated successfully, but these errors were encountered: