invenio-vocabularies 9.1.2__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- invenio_vocabularies/__init__.py +16 -0
- invenio_vocabularies/administration/__init__.py +10 -0
- invenio_vocabularies/administration/views/__init__.py +10 -0
- invenio_vocabularies/administration/views/vocabularies.py +43 -0
- invenio_vocabularies/alembic/17c703ce1eb7_create_names_table.py +54 -0
- invenio_vocabularies/alembic/3ba812d80559_add_internal_name_id.py +36 -0
- invenio_vocabularies/alembic/4a9a4fd235f8_create_vocabulary_schemes.py +37 -0
- invenio_vocabularies/alembic/4f365fced43f_create_vocabularies_tables.py +92 -0
- invenio_vocabularies/alembic/55a700f897b6_add_names_and_afiliations_pid_column.py +96 -0
- invenio_vocabularies/alembic/6312f33645c1_create_affiliations_table.py +54 -0
- invenio_vocabularies/alembic/676dd587542d_create_funders_vocabulary_table.py +58 -0
- invenio_vocabularies/alembic/8ff82dfb0be8_create_vocabularies_branch.py +28 -0
- invenio_vocabularies/alembic/__init__.py +9 -0
- invenio_vocabularies/alembic/af2457652217_drop_unique_constraint_from_internal_id.py +37 -0
- invenio_vocabularies/alembic/e1146238edd3_create_awards_table.py +56 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/.eslintrc.yml +11 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/.prettierrc +1 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/index.js +7 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/package.json +25 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/AwardResults.js +95 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/CustomAwardForm.js +139 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FunderDropdown.js +87 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingField.js +244 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingField.test.js +1 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingFieldItem.js +152 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingModal.js +246 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/NoAwardResults.js +37 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/index.js +8 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/index.js +7 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/index.js +7 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/index.js +7 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/i18next.js +36 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/_generatedTranslations.js +66 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ar/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ar/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/bg/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/bg/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ca/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ca/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/cs/messages.po +97 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/cs/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/da/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/da/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/de/messages.po +98 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/de/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/el/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/el/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/en/messages.po +88 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/en/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/es/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/es/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/et/messages.po +95 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/et/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/fa/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/fa/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/fr/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/fr/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/hr/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/hr/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/hu/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/hu/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/index.js +24 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/it/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/it/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ja/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ja/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ka/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ka/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ko/messages.po +90 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ko/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/lt/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/lt/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/no/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/no/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/pl/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/pl/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/pt/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/pt/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ro/messages.po +95 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ro/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ru/messages.po +95 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/ru/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/sk/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/sk/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/sv/messages.po +98 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/sv/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/tr/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/tr/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/uk/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/uk/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/zh_CN/messages.po +96 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/zh_CN/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/zh_TW/messages.po +94 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/zh_TW/translations.json +28 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/package.json +19 -0
- invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/translations.pot +88 -0
- invenio_vocabularies/cli.py +175 -0
- invenio_vocabularies/config.py +231 -0
- invenio_vocabularies/contrib/__init__.py +9 -0
- invenio_vocabularies/contrib/affiliations/__init__.py +20 -0
- invenio_vocabularies/contrib/affiliations/affiliations.py +61 -0
- invenio_vocabularies/contrib/affiliations/api.py +13 -0
- invenio_vocabularies/contrib/affiliations/config.py +79 -0
- invenio_vocabularies/contrib/affiliations/datastreams.py +301 -0
- invenio_vocabularies/contrib/affiliations/facets.py +36 -0
- invenio_vocabularies/contrib/affiliations/jsonschemas/__init__.py +9 -0
- invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json +63 -0
- invenio_vocabularies/contrib/affiliations/mappings/__init__.py +10 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v1/__init__.py +9 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v1.0.0.json +112 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json +171 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v2/__init__.py +9 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v1.0.0.json +112 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json +171 -0
- invenio_vocabularies/contrib/affiliations/mappings/v7/__init__.py +9 -0
- invenio_vocabularies/contrib/affiliations/mappings/v7/affiliations/affiliation-v1.0.0.json +112 -0
- invenio_vocabularies/contrib/affiliations/models.py +13 -0
- invenio_vocabularies/contrib/affiliations/resources.py +16 -0
- invenio_vocabularies/contrib/affiliations/schema.py +71 -0
- invenio_vocabularies/contrib/affiliations/services.py +15 -0
- invenio_vocabularies/contrib/awards/__init__.py +19 -0
- invenio_vocabularies/contrib/awards/api.py +13 -0
- invenio_vocabularies/contrib/awards/awards.py +96 -0
- invenio_vocabularies/contrib/awards/config.py +59 -0
- invenio_vocabularies/contrib/awards/datastreams.py +372 -0
- invenio_vocabularies/contrib/awards/jsonschemas/__init__.py +9 -0
- invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json +91 -0
- invenio_vocabularies/contrib/awards/mappings/__init__.py +9 -0
- invenio_vocabularies/contrib/awards/mappings/os-v1/__init__.py +9 -0
- invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json +147 -0
- invenio_vocabularies/contrib/awards/mappings/os-v2/__init__.py +9 -0
- invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json +147 -0
- invenio_vocabularies/contrib/awards/mappings/v7/__init__.py +9 -0
- invenio_vocabularies/contrib/awards/mappings/v7/awards/award-v1.0.0.json +147 -0
- invenio_vocabularies/contrib/awards/models.py +13 -0
- invenio_vocabularies/contrib/awards/resources.py +16 -0
- invenio_vocabularies/contrib/awards/schema.py +119 -0
- invenio_vocabularies/contrib/awards/serializer.py +47 -0
- invenio_vocabularies/contrib/awards/services.py +15 -0
- invenio_vocabularies/contrib/common/__init__.py +9 -0
- invenio_vocabularies/contrib/common/openaire/__init__.py +9 -0
- invenio_vocabularies/contrib/common/openaire/datastreams.py +84 -0
- invenio_vocabularies/contrib/common/ror/__init__.py +9 -0
- invenio_vocabularies/contrib/common/ror/datastreams.py +230 -0
- invenio_vocabularies/contrib/funders/__init__.py +19 -0
- invenio_vocabularies/contrib/funders/api.py +13 -0
- invenio_vocabularies/contrib/funders/config.py +78 -0
- invenio_vocabularies/contrib/funders/datastreams.py +97 -0
- invenio_vocabularies/contrib/funders/facets.py +36 -0
- invenio_vocabularies/contrib/funders/funders.py +72 -0
- invenio_vocabularies/contrib/funders/jsonschemas/__init__.py +9 -0
- invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json +65 -0
- invenio_vocabularies/contrib/funders/mappings/__init__.py +9 -0
- invenio_vocabularies/contrib/funders/mappings/os-v1/__init__.py +9 -0
- invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v1.0.0.json +90 -0
- invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json +156 -0
- invenio_vocabularies/contrib/funders/mappings/os-v2/__init__.py +9 -0
- invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v1.0.0.json +90 -0
- invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json +156 -0
- invenio_vocabularies/contrib/funders/mappings/v7/__init__.py +9 -0
- invenio_vocabularies/contrib/funders/mappings/v7/funders/funder-v1.0.0.json +90 -0
- invenio_vocabularies/contrib/funders/models.py +13 -0
- invenio_vocabularies/contrib/funders/resources.py +16 -0
- invenio_vocabularies/contrib/funders/schema.py +88 -0
- invenio_vocabularies/contrib/funders/serializer.py +33 -0
- invenio_vocabularies/contrib/funders/services.py +15 -0
- invenio_vocabularies/contrib/names/__init__.py +19 -0
- invenio_vocabularies/contrib/names/api.py +13 -0
- invenio_vocabularies/contrib/names/components.py +24 -0
- invenio_vocabularies/contrib/names/config.py +75 -0
- invenio_vocabularies/contrib/names/datastreams.py +483 -0
- invenio_vocabularies/contrib/names/jsonschemas/__init__.py +9 -0
- invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json +68 -0
- invenio_vocabularies/contrib/names/mappings/__init__.py +9 -0
- invenio_vocabularies/contrib/names/mappings/os-v1/__init__.py +9 -0
- invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v1.0.0.json +101 -0
- invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json +165 -0
- invenio_vocabularies/contrib/names/mappings/os-v2/__init__.py +9 -0
- invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v1.0.0.json +101 -0
- invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json +165 -0
- invenio_vocabularies/contrib/names/mappings/v7/__init__.py +9 -0
- invenio_vocabularies/contrib/names/mappings/v7/names/name-v1.0.0.json +101 -0
- invenio_vocabularies/contrib/names/models.py +13 -0
- invenio_vocabularies/contrib/names/names.py +80 -0
- invenio_vocabularies/contrib/names/permissions.py +30 -0
- invenio_vocabularies/contrib/names/resources.py +54 -0
- invenio_vocabularies/contrib/names/s3client.py +50 -0
- invenio_vocabularies/contrib/names/schema.py +121 -0
- invenio_vocabularies/contrib/names/services.py +64 -0
- invenio_vocabularies/contrib/subjects/__init__.py +22 -0
- invenio_vocabularies/contrib/subjects/api.py +14 -0
- invenio_vocabularies/contrib/subjects/config.py +90 -0
- invenio_vocabularies/contrib/subjects/datastreams.py +63 -0
- invenio_vocabularies/contrib/subjects/euroscivoc/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/euroscivoc/datastreams.py +101 -0
- invenio_vocabularies/contrib/subjects/facets.py +23 -0
- invenio_vocabularies/contrib/subjects/gemet/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/gemet/datastreams.py +140 -0
- invenio_vocabularies/contrib/subjects/jsonschemas/__init__.py +10 -0
- invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json +69 -0
- invenio_vocabularies/contrib/subjects/mappings/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/mappings/os-v1/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json +96 -0
- invenio_vocabularies/contrib/subjects/mappings/os-v2/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json +96 -0
- invenio_vocabularies/contrib/subjects/mappings/v7/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/mappings/v7/subjects/subject-v1.0.0.json +96 -0
- invenio_vocabularies/contrib/subjects/mesh/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/mesh/datastreams.py +48 -0
- invenio_vocabularies/contrib/subjects/models.py +14 -0
- invenio_vocabularies/contrib/subjects/nvs/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/nvs/datastreams.py +114 -0
- invenio_vocabularies/contrib/subjects/resources.py +17 -0
- invenio_vocabularies/contrib/subjects/schema.py +101 -0
- invenio_vocabularies/contrib/subjects/services.py +30 -0
- invenio_vocabularies/contrib/subjects/subjects.py +55 -0
- invenio_vocabularies/datastreams/__init__.py +18 -0
- invenio_vocabularies/datastreams/datastreams.py +239 -0
- invenio_vocabularies/datastreams/errors.py +29 -0
- invenio_vocabularies/datastreams/factories.py +86 -0
- invenio_vocabularies/datastreams/readers.py +448 -0
- invenio_vocabularies/datastreams/tasks.py +115 -0
- invenio_vocabularies/datastreams/transformers.py +130 -0
- invenio_vocabularies/datastreams/writers.py +222 -0
- invenio_vocabularies/datastreams/xml.py +34 -0
- invenio_vocabularies/ext.py +179 -0
- invenio_vocabularies/factories.py +193 -0
- invenio_vocabularies/fixtures.py +52 -0
- invenio_vocabularies/jobs.py +207 -0
- invenio_vocabularies/proxies.py +27 -0
- invenio_vocabularies/records/__init__.py +9 -0
- invenio_vocabularies/records/api.py +53 -0
- invenio_vocabularies/records/jsonschemas/__init__.py +9 -0
- invenio_vocabularies/records/jsonschemas/vocabularies/definitions-v1.0.0.json +30 -0
- invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json +55 -0
- invenio_vocabularies/records/mappings/__init__.py +9 -0
- invenio_vocabularies/records/mappings/os-v1/__init__.py +9 -0
- invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +109 -0
- invenio_vocabularies/records/mappings/os-v2/__init__.py +9 -0
- invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +109 -0
- invenio_vocabularies/records/mappings/v7/__init__.py +9 -0
- invenio_vocabularies/records/mappings/v7/vocabularies/vocabulary-v1.0.0.json +109 -0
- invenio_vocabularies/records/models.py +90 -0
- invenio_vocabularies/records/pidprovider.py +118 -0
- invenio_vocabularies/records/systemfields/__init__.py +16 -0
- invenio_vocabularies/records/systemfields/pid.py +125 -0
- invenio_vocabularies/records/systemfields/relations.py +51 -0
- invenio_vocabularies/resources/__init__.py +23 -0
- invenio_vocabularies/resources/config.py +105 -0
- invenio_vocabularies/resources/resource.py +156 -0
- invenio_vocabularies/resources/schema.py +21 -0
- invenio_vocabularies/resources/serializer.py +39 -0
- invenio_vocabularies/services/__init__.py +19 -0
- invenio_vocabularies/services/components.py +58 -0
- invenio_vocabularies/services/config.py +173 -0
- invenio_vocabularies/services/custom_fields/__init__.py +17 -0
- invenio_vocabularies/services/custom_fields/subject.py +82 -0
- invenio_vocabularies/services/custom_fields/vocabulary.py +96 -0
- invenio_vocabularies/services/facets.py +114 -0
- invenio_vocabularies/services/generators.py +38 -0
- invenio_vocabularies/services/permissions.py +30 -0
- invenio_vocabularies/services/querystr.py +57 -0
- invenio_vocabularies/services/results.py +110 -0
- invenio_vocabularies/services/schema.py +163 -0
- invenio_vocabularies/services/service.py +189 -0
- invenio_vocabularies/services/tasks.py +38 -0
- invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/subjects.html +23 -0
- invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/vocabularies-list.html +12 -0
- invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/vocabulary-details.html +71 -0
- invenio_vocabularies/translations/ar/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ar/LC_MESSAGES/messages.po +277 -0
- invenio_vocabularies/translations/bg/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/bg/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/ca/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ca/LC_MESSAGES/messages.po +276 -0
- invenio_vocabularies/translations/cs/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/cs/LC_MESSAGES/messages.po +281 -0
- invenio_vocabularies/translations/da/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/da/LC_MESSAGES/messages.po +271 -0
- invenio_vocabularies/translations/de/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/de/LC_MESSAGES/messages.po +293 -0
- invenio_vocabularies/translations/el/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/el/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/es/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/es/LC_MESSAGES/messages.po +281 -0
- invenio_vocabularies/translations/et/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/et/LC_MESSAGES/messages.po +276 -0
- invenio_vocabularies/translations/fa/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fa/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/fr/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fr/LC_MESSAGES/messages.po +279 -0
- invenio_vocabularies/translations/hr/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/hr/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/hu/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/hu/LC_MESSAGES/messages.po +280 -0
- invenio_vocabularies/translations/it/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/it/LC_MESSAGES/messages.po +277 -0
- invenio_vocabularies/translations/ja/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ja/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/ka/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ka/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/ko/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ko/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/lt/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/lt/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/messages.pot +270 -0
- invenio_vocabularies/translations/no/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/no/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/pl/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/pl/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/pt/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/pt/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/ro/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ro/LC_MESSAGES/messages.po +280 -0
- invenio_vocabularies/translations/ru/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ru/LC_MESSAGES/messages.po +276 -0
- invenio_vocabularies/translations/sk/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/sk/LC_MESSAGES/messages.po +276 -0
- invenio_vocabularies/translations/sv/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/sv/LC_MESSAGES/messages.po +280 -0
- invenio_vocabularies/translations/tr/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/tr/LC_MESSAGES/messages.po +277 -0
- invenio_vocabularies/translations/uk/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/uk/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/translations/zh_CN/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/zh_CN/LC_MESSAGES/messages.po +276 -0
- invenio_vocabularies/translations/zh_TW/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/zh_TW/LC_MESSAGES/messages.po +275 -0
- invenio_vocabularies/views.py +53 -0
- invenio_vocabularies/webpack.py +51 -0
- invenio_vocabularies-9.1.2.dist-info/METADATA +517 -0
- invenio_vocabularies-9.1.2.dist-info/RECORD +337 -0
- invenio_vocabularies-9.1.2.dist-info/WHEEL +6 -0
- invenio_vocabularies-9.1.2.dist-info/entry_points.txt +73 -0
- invenio_vocabularies-9.1.2.dist-info/licenses/AUTHORS.rst +13 -0
- invenio_vocabularies-9.1.2.dist-info/licenses/LICENSE +21 -0
- invenio_vocabularies-9.1.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2022-2024 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Records-Resources is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""Relations system fields."""
|
|
10
|
+
|
|
11
|
+
from flask import current_app
|
|
12
|
+
from invenio_records.systemfields import RelationsField
|
|
13
|
+
from werkzeug.utils import cached_property
|
|
14
|
+
|
|
15
|
+
from ..api import Vocabulary
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CustomFieldsRelation(RelationsField):
|
|
19
|
+
"""Relation field to manage custom fields.
|
|
20
|
+
|
|
21
|
+
Iterates through all configured custom fields and collects the ones
|
|
22
|
+
defining a relation dependency e.g vocabularies.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, fields_var):
|
|
26
|
+
"""Initialize the field."""
|
|
27
|
+
super().__init__()
|
|
28
|
+
self._fields_var = fields_var
|
|
29
|
+
|
|
30
|
+
@cached_property
|
|
31
|
+
def _fields(self):
|
|
32
|
+
"""Loads custom fields relations from config."""
|
|
33
|
+
custom_fields = current_app.config.get(self._fields_var, {})
|
|
34
|
+
|
|
35
|
+
relations = {}
|
|
36
|
+
for cf in custom_fields:
|
|
37
|
+
if getattr(cf, "relation_cls", None):
|
|
38
|
+
relations[cf.name] = cf.relation_cls(
|
|
39
|
+
f"custom_fields.{cf.name}",
|
|
40
|
+
keys=cf.field_keys,
|
|
41
|
+
pid_field=cf.pid_field,
|
|
42
|
+
cache_key=cf.vocabulary_id,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return relations
|
|
46
|
+
|
|
47
|
+
def __set__(self, instance, values):
|
|
48
|
+
"""Setting the attribute."""
|
|
49
|
+
raise ValueError(
|
|
50
|
+
f"This field can only be set through config ({self._fields_var})"
|
|
51
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""Resources module."""
|
|
10
|
+
|
|
11
|
+
from invenio_vocabularies.resources.schema import L10NString, VocabularyL10Schema
|
|
12
|
+
|
|
13
|
+
from .config import VocabulariesResourceConfig, VocabularyTypeResourceConfig
|
|
14
|
+
from .resource import VocabulariesAdminResource, VocabulariesResource
|
|
15
|
+
|
|
16
|
+
__all__ = (
|
|
17
|
+
"VocabularyL10Schema",
|
|
18
|
+
"L10NString",
|
|
19
|
+
"VocabulariesResourceConfig",
|
|
20
|
+
"VocabularyTypeResourceConfig",
|
|
21
|
+
"VocabulariesAdminResource",
|
|
22
|
+
"VocabulariesResource",
|
|
23
|
+
)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2024 CERN.
|
|
4
|
+
# Copyright (C) 2024 University of Münster.
|
|
5
|
+
#
|
|
6
|
+
# Invenio-Vocabularies is free software; you can redistringibute it and/or modify it
|
|
7
|
+
# under the terms of the MIT License; see LICENSE file for more details.
|
|
8
|
+
|
|
9
|
+
"""Resources config."""
|
|
10
|
+
|
|
11
|
+
import marshmallow as ma
|
|
12
|
+
from flask_resources import (
|
|
13
|
+
BaseListSchema,
|
|
14
|
+
HTTPJSONException,
|
|
15
|
+
JSONSerializer,
|
|
16
|
+
MarshmallowSerializer,
|
|
17
|
+
ResourceConfig,
|
|
18
|
+
ResponseHandler,
|
|
19
|
+
create_error_handler,
|
|
20
|
+
)
|
|
21
|
+
from invenio_records_resources.resources import (
|
|
22
|
+
RecordResource,
|
|
23
|
+
RecordResourceConfig,
|
|
24
|
+
SearchRequestArgsSchema,
|
|
25
|
+
)
|
|
26
|
+
from invenio_records_resources.resources.errors import ErrorHandlersMixin
|
|
27
|
+
from invenio_records_resources.resources.records.args import SearchRequestArgsSchema
|
|
28
|
+
from invenio_records_resources.resources.records.headers import etag_headers
|
|
29
|
+
from invenio_records_resources.services.base.config import ConfiguratorMixin
|
|
30
|
+
|
|
31
|
+
from .serializer import VocabularyL10NItemSchema
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class VocabularySearchRequestArgsSchema(SearchRequestArgsSchema):
|
|
35
|
+
"""Vocabularies search request parameters."""
|
|
36
|
+
|
|
37
|
+
tags = ma.fields.Str()
|
|
38
|
+
active = ma.fields.Boolean()
|
|
39
|
+
status = ma.fields.Boolean()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class VocabulariesResourceConfig(RecordResourceConfig):
|
|
43
|
+
"""Vocabulary resource configuration."""
|
|
44
|
+
|
|
45
|
+
blueprint_name = "vocabularies"
|
|
46
|
+
url_prefix = "/vocabularies"
|
|
47
|
+
routes = {
|
|
48
|
+
"list": "/<type>",
|
|
49
|
+
"item": "/<type>/<pid_value>",
|
|
50
|
+
"tasks": "/tasks",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
request_view_args = {
|
|
54
|
+
"pid_value": ma.fields.Str(),
|
|
55
|
+
"type": ma.fields.Str(required=True),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
request_search_args = VocabularySearchRequestArgsSchema
|
|
59
|
+
|
|
60
|
+
response_handlers = {
|
|
61
|
+
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
|
|
62
|
+
"application/vnd.inveniordm.v1+json": ResponseHandler(
|
|
63
|
+
MarshmallowSerializer(
|
|
64
|
+
format_serializer_cls=JSONSerializer,
|
|
65
|
+
object_schema_cls=VocabularyL10NItemSchema,
|
|
66
|
+
list_schema_cls=BaseListSchema,
|
|
67
|
+
),
|
|
68
|
+
headers=etag_headers,
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class VocabularyTypeResourceConfig(ResourceConfig, ConfiguratorMixin):
|
|
74
|
+
"""Vocabulary list resource config."""
|
|
75
|
+
|
|
76
|
+
# /vocabulary/vocabulary_id
|
|
77
|
+
# Blueprint configuration
|
|
78
|
+
blueprint_name = "vocabulary_types"
|
|
79
|
+
url_prefix = "/vocabularies"
|
|
80
|
+
|
|
81
|
+
routes = {"list": "/"}
|
|
82
|
+
|
|
83
|
+
# Request parsing
|
|
84
|
+
request_read_args = {}
|
|
85
|
+
request_view_args = {
|
|
86
|
+
"pid_value": ma.fields.String,
|
|
87
|
+
"type": ma.fields.String,
|
|
88
|
+
}
|
|
89
|
+
request_search_args = VocabularySearchRequestArgsSchema
|
|
90
|
+
|
|
91
|
+
error_handlers = {
|
|
92
|
+
**ErrorHandlersMixin.error_handlers,
|
|
93
|
+
# TODO: Add custom error handlers here
|
|
94
|
+
}
|
|
95
|
+
response_handlers = {
|
|
96
|
+
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
|
|
97
|
+
"application/vnd.inveniordm.v1+json": ResponseHandler(
|
|
98
|
+
MarshmallowSerializer(
|
|
99
|
+
format_serializer_cls=JSONSerializer,
|
|
100
|
+
object_schema_cls=VocabularyL10NItemSchema,
|
|
101
|
+
list_schema_cls=BaseListSchema,
|
|
102
|
+
),
|
|
103
|
+
headers=etag_headers,
|
|
104
|
+
),
|
|
105
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
|
+
# Copyright (C) 2024 Uni Münster.
|
|
5
|
+
#
|
|
6
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
8
|
+
# details.
|
|
9
|
+
|
|
10
|
+
"""Vocabulary resource."""
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
|
|
14
|
+
import marshmallow as ma
|
|
15
|
+
from flask import g
|
|
16
|
+
from flask_resources import (
|
|
17
|
+
BaseListSchema,
|
|
18
|
+
JSONSerializer,
|
|
19
|
+
MarshmallowSerializer,
|
|
20
|
+
ResponseHandler,
|
|
21
|
+
resource_requestctx,
|
|
22
|
+
response_handler,
|
|
23
|
+
)
|
|
24
|
+
from invenio_access.permissions import system_identity
|
|
25
|
+
from invenio_records_resources.resources import (
|
|
26
|
+
RecordResource,
|
|
27
|
+
RecordResourceConfig,
|
|
28
|
+
SearchRequestArgsSchema,
|
|
29
|
+
)
|
|
30
|
+
from invenio_records_resources.resources.records.headers import etag_headers
|
|
31
|
+
from invenio_records_resources.resources.records.resource import (
|
|
32
|
+
request_data,
|
|
33
|
+
request_headers,
|
|
34
|
+
request_search_args,
|
|
35
|
+
request_view_args,
|
|
36
|
+
route,
|
|
37
|
+
)
|
|
38
|
+
from invenio_records_resources.resources.records.utils import search_preference
|
|
39
|
+
from marshmallow import fields
|
|
40
|
+
|
|
41
|
+
from .serializer import VocabularyL10NItemSchema
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# Resource
|
|
46
|
+
#
|
|
47
|
+
class VocabulariesResource(RecordResource):
|
|
48
|
+
"""Resource for generic vocabularies.
|
|
49
|
+
|
|
50
|
+
Provide the API /api/vocabularies/
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def create_url_rules(self):
|
|
54
|
+
"""Create the URL rules for the record resource."""
|
|
55
|
+
routes = self.config.routes
|
|
56
|
+
rules = super().create_url_rules()
|
|
57
|
+
|
|
58
|
+
rules.append(
|
|
59
|
+
route("POST", routes["tasks"], self.launch),
|
|
60
|
+
)
|
|
61
|
+
return rules
|
|
62
|
+
|
|
63
|
+
@request_search_args
|
|
64
|
+
@request_view_args
|
|
65
|
+
@response_handler(many=True)
|
|
66
|
+
def search(self):
|
|
67
|
+
"""Perform a search over the items."""
|
|
68
|
+
hits = self.service.search(
|
|
69
|
+
identity=g.identity,
|
|
70
|
+
params=resource_requestctx.args,
|
|
71
|
+
type=resource_requestctx.view_args["type"],
|
|
72
|
+
search_preference=search_preference(),
|
|
73
|
+
)
|
|
74
|
+
return hits.to_dict(), 200
|
|
75
|
+
|
|
76
|
+
@request_view_args
|
|
77
|
+
@request_data
|
|
78
|
+
@response_handler()
|
|
79
|
+
def create(self):
|
|
80
|
+
"""Create an item."""
|
|
81
|
+
item = self.service.create(
|
|
82
|
+
g.identity,
|
|
83
|
+
resource_requestctx.data or {},
|
|
84
|
+
)
|
|
85
|
+
return item.to_dict(), 201
|
|
86
|
+
|
|
87
|
+
@request_view_args
|
|
88
|
+
@response_handler()
|
|
89
|
+
def read(self):
|
|
90
|
+
"""Read an item."""
|
|
91
|
+
pid_value = (
|
|
92
|
+
resource_requestctx.view_args["type"],
|
|
93
|
+
resource_requestctx.view_args["pid_value"],
|
|
94
|
+
)
|
|
95
|
+
item = self.service.read(g.identity, pid_value)
|
|
96
|
+
return item.to_dict(), 200
|
|
97
|
+
|
|
98
|
+
@request_headers
|
|
99
|
+
@request_view_args
|
|
100
|
+
@request_data
|
|
101
|
+
@response_handler()
|
|
102
|
+
def update(self):
|
|
103
|
+
"""Update an item."""
|
|
104
|
+
pid_value = (
|
|
105
|
+
resource_requestctx.view_args["type"],
|
|
106
|
+
resource_requestctx.view_args["pid_value"],
|
|
107
|
+
)
|
|
108
|
+
item = self.service.update(
|
|
109
|
+
g.identity,
|
|
110
|
+
pid_value,
|
|
111
|
+
resource_requestctx.data,
|
|
112
|
+
revision_id=resource_requestctx.headers.get("if_match"),
|
|
113
|
+
)
|
|
114
|
+
return item.to_dict(), 200
|
|
115
|
+
|
|
116
|
+
@request_headers
|
|
117
|
+
@request_view_args
|
|
118
|
+
def delete(self):
|
|
119
|
+
"""Delete an item."""
|
|
120
|
+
pid_value = (
|
|
121
|
+
resource_requestctx.view_args["type"],
|
|
122
|
+
resource_requestctx.view_args["pid_value"],
|
|
123
|
+
)
|
|
124
|
+
self.service.delete(
|
|
125
|
+
g.identity,
|
|
126
|
+
pid_value,
|
|
127
|
+
revision_id=resource_requestctx.headers.get("if_match"),
|
|
128
|
+
)
|
|
129
|
+
return "", 204
|
|
130
|
+
|
|
131
|
+
@request_data
|
|
132
|
+
def launch(self):
|
|
133
|
+
"""Create a task."""
|
|
134
|
+
self.service.launch(g.identity, resource_requestctx.data or {})
|
|
135
|
+
return "", 202
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class VocabulariesAdminResource(RecordResource):
|
|
139
|
+
"""Resource for vocabularies admin interface."""
|
|
140
|
+
|
|
141
|
+
def create_url_rules(self):
|
|
142
|
+
"""Create the URL rules for the record resource."""
|
|
143
|
+
routes = self.config.routes
|
|
144
|
+
|
|
145
|
+
rules = [route("GET", routes["list"], self.search)]
|
|
146
|
+
|
|
147
|
+
return rules
|
|
148
|
+
|
|
149
|
+
@request_search_args
|
|
150
|
+
@response_handler(many=True)
|
|
151
|
+
def search(self):
|
|
152
|
+
"""Return information about _all_ vocabularies."""
|
|
153
|
+
identity = g.identity
|
|
154
|
+
hits = self.service.search(identity, params=resource_requestctx.args)
|
|
155
|
+
|
|
156
|
+
return hits.to_dict(), 200
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
|
+
# Copyright (C) 2021 Northwestern University.
|
|
5
|
+
#
|
|
6
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
8
|
+
# details.
|
|
9
|
+
|
|
10
|
+
"""Vocabulary resource schema."""
|
|
11
|
+
|
|
12
|
+
from marshmallow import Schema, fields
|
|
13
|
+
|
|
14
|
+
from invenio_vocabularies.resources.serializer import L10NString
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class VocabularyL10Schema(Schema):
|
|
18
|
+
"""Vocabulary schema."""
|
|
19
|
+
|
|
20
|
+
id = fields.String()
|
|
21
|
+
title = L10NString(data_key="title_l10n")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2021 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""Localization serializer for Vocabularies."""
|
|
10
|
+
|
|
11
|
+
from functools import partial
|
|
12
|
+
|
|
13
|
+
from flask import current_app
|
|
14
|
+
from flask_resources import BaseListSchema, BaseObjectSchema
|
|
15
|
+
from invenio_i18n import get_locale
|
|
16
|
+
from marshmallow import fields
|
|
17
|
+
from marshmallow_utils.fields import BabelGettextDictField
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def current_default_locale():
|
|
21
|
+
"""Get the Flask app's default locale."""
|
|
22
|
+
if current_app:
|
|
23
|
+
return current_app.config.get("BABEL_DEFAULT_LOCALE", "en")
|
|
24
|
+
# Use english by default if not specified
|
|
25
|
+
return "en"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
L10NString = partial(BabelGettextDictField, get_locale, current_default_locale)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class VocabularyL10NItemSchema(BaseObjectSchema):
|
|
32
|
+
"""Vocabulary serializer schema."""
|
|
33
|
+
|
|
34
|
+
id = fields.String(dump_only=True)
|
|
35
|
+
title = L10NString(data_key="title_l10n")
|
|
36
|
+
description = L10NString(data_key="description_l10n")
|
|
37
|
+
props = fields.Dict(dump_only=True)
|
|
38
|
+
icon = fields.String(dump_only=True)
|
|
39
|
+
tags = fields.List(fields.Str(), dump_only=True)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""Services module."""
|
|
10
|
+
|
|
11
|
+
from .config import VocabulariesServiceConfig, VocabularyTypesServiceConfig
|
|
12
|
+
from .service import VocabulariesService, VocabularyTypeService
|
|
13
|
+
|
|
14
|
+
__all__ = (
|
|
15
|
+
"VocabulariesService",
|
|
16
|
+
"VocabularyTypeService",
|
|
17
|
+
"VocabulariesServiceConfig",
|
|
18
|
+
"VocabularyTypesServiceConfig",
|
|
19
|
+
)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2020-2021 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""Vocabulary components."""
|
|
10
|
+
|
|
11
|
+
from invenio_i18n import lazy_gettext as _
|
|
12
|
+
from invenio_records_resources.services.records.components import ServiceComponent
|
|
13
|
+
from marshmallow import ValidationError
|
|
14
|
+
from sqlalchemy.orm.exc import NoResultFound
|
|
15
|
+
|
|
16
|
+
from ..records.models import VocabularyType
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class VocabularyTypeComponent(ServiceComponent):
|
|
20
|
+
"""Set the record's vocabulary type."""
|
|
21
|
+
|
|
22
|
+
def _set_type(self, data, record):
|
|
23
|
+
type_id = data.pop("type", None)
|
|
24
|
+
if type_id:
|
|
25
|
+
try:
|
|
26
|
+
record.type = VocabularyType.query.filter_by(id=type_id["id"]).one()
|
|
27
|
+
except NoResultFound:
|
|
28
|
+
raise ValidationError(
|
|
29
|
+
_("The vocabulary type does not exists."),
|
|
30
|
+
field_name="type",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def create(self, identity, data=None, record=None, **kwargs):
|
|
34
|
+
"""Inject vocabulary type to the record."""
|
|
35
|
+
self._set_type(data, record)
|
|
36
|
+
|
|
37
|
+
def update(self, identity, data=None, record=None, **kwargs):
|
|
38
|
+
"""Inject vocabulary type to the record."""
|
|
39
|
+
self._set_type(data, record)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class PIDComponent(ServiceComponent):
|
|
43
|
+
"""PID registration component."""
|
|
44
|
+
|
|
45
|
+
def create(self, identity, data=None, record=None, **kwargs):
|
|
46
|
+
"""Create PID when record is created.."""
|
|
47
|
+
# We create the PID after all the data has been initialized. so that
|
|
48
|
+
# we can rely on having the 'id' and type set.
|
|
49
|
+
self.service.record_cls.pid.create(record)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ModelPIDComponent(PIDComponent):
|
|
53
|
+
"""Model PID registration component."""
|
|
54
|
+
|
|
55
|
+
def update(self, identity, data=None, record=None, **kwargs):
|
|
56
|
+
"""Update an existing record."""
|
|
57
|
+
record.pop("pid", None)
|
|
58
|
+
record.pop("id", None)
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2024 CERN.
|
|
4
|
+
# Copyright (C) 2024 University of Münster.
|
|
5
|
+
#
|
|
6
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
8
|
+
# details.
|
|
9
|
+
|
|
10
|
+
"""Vocabulary services configs."""
|
|
11
|
+
|
|
12
|
+
import sqlalchemy as sa
|
|
13
|
+
from flask import current_app
|
|
14
|
+
from invenio_i18n import lazy_gettext as _
|
|
15
|
+
from invenio_records_resources.services import (
|
|
16
|
+
Link,
|
|
17
|
+
RecordServiceConfig,
|
|
18
|
+
SearchOptions,
|
|
19
|
+
pagination_links,
|
|
20
|
+
)
|
|
21
|
+
from invenio_records_resources.services.base import ConditionalLink
|
|
22
|
+
from invenio_records_resources.services.records.components import DataComponent
|
|
23
|
+
from invenio_records_resources.services.records.params import (
|
|
24
|
+
FilterParam,
|
|
25
|
+
SuggestQueryParser,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
from ..records.api import Vocabulary
|
|
29
|
+
from ..records.models import VocabularyType
|
|
30
|
+
from . import results
|
|
31
|
+
from .components import PIDComponent, VocabularyTypeComponent
|
|
32
|
+
from .permissions import PermissionPolicy
|
|
33
|
+
from .schema import TaskSchema, VocabularySchema
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def is_custom_vocabulary_type(vocabulary_type, context):
|
|
37
|
+
"""Check if the vocabulary type is a custom vocabulary type."""
|
|
38
|
+
return vocabulary_type["id"] in current_app.config.get(
|
|
39
|
+
"VOCABULARIES_CUSTOM_VOCABULARY_TYPES", []
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class VocabularySearchOptions(SearchOptions):
|
|
44
|
+
"""Search options for vocabularies."""
|
|
45
|
+
|
|
46
|
+
params_interpreters_cls = [
|
|
47
|
+
FilterParam.factory(param="tags", field="tags"),
|
|
48
|
+
] + SearchOptions.params_interpreters_cls
|
|
49
|
+
|
|
50
|
+
suggest_parser_cls = SuggestQueryParser.factory(
|
|
51
|
+
fields=[
|
|
52
|
+
"id.text^100",
|
|
53
|
+
"id.text._2gram",
|
|
54
|
+
"id.text._3gram",
|
|
55
|
+
"title.en^5",
|
|
56
|
+
"title.en._2gram",
|
|
57
|
+
"title.en._3gram",
|
|
58
|
+
],
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
sort_default = "bestmatch"
|
|
62
|
+
|
|
63
|
+
sort_default_no_query = "title"
|
|
64
|
+
|
|
65
|
+
sort_options = {
|
|
66
|
+
"bestmatch": dict(
|
|
67
|
+
title=_("Best match"),
|
|
68
|
+
fields=["_score"], # ES defaults to desc on `_score` field
|
|
69
|
+
),
|
|
70
|
+
"title": dict(
|
|
71
|
+
title=_("Title"),
|
|
72
|
+
fields=["title_sort"],
|
|
73
|
+
),
|
|
74
|
+
"newest": dict(
|
|
75
|
+
title=_("Newest"),
|
|
76
|
+
fields=["-created"],
|
|
77
|
+
),
|
|
78
|
+
"oldest": dict(
|
|
79
|
+
title=_("Oldest"),
|
|
80
|
+
fields=["created"],
|
|
81
|
+
),
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class VocabularyTypeSearchOptions(SearchOptions):
|
|
86
|
+
"""Search options for vocabulary types."""
|
|
87
|
+
|
|
88
|
+
sort_options = {
|
|
89
|
+
"id": dict(
|
|
90
|
+
title=_("ID"),
|
|
91
|
+
fields=["id"],
|
|
92
|
+
),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
sort_default = "id"
|
|
96
|
+
|
|
97
|
+
sort_default_no_query = "id"
|
|
98
|
+
|
|
99
|
+
sort_direction_options = {
|
|
100
|
+
"asc": dict(title=_("Ascending"), fn=sa.asc),
|
|
101
|
+
"desc": dict(title=_("Descending"), fn=sa.desc),
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
sort_direction_default = "asc"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class VocabulariesServiceConfig(RecordServiceConfig):
|
|
108
|
+
"""Vocabulary service configuration."""
|
|
109
|
+
|
|
110
|
+
service_id = "vocabularies"
|
|
111
|
+
indexer_queue_name = "vocabularies"
|
|
112
|
+
permission_policy_cls = PermissionPolicy
|
|
113
|
+
record_cls = Vocabulary
|
|
114
|
+
schema = VocabularySchema
|
|
115
|
+
task_schema = TaskSchema
|
|
116
|
+
|
|
117
|
+
search = VocabularySearchOptions
|
|
118
|
+
|
|
119
|
+
components = [
|
|
120
|
+
# Order of components are important!
|
|
121
|
+
VocabularyTypeComponent,
|
|
122
|
+
DataComponent,
|
|
123
|
+
PIDComponent,
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
links_item = {
|
|
127
|
+
"self": Link(
|
|
128
|
+
"{+api}/vocabularies/{type}/{id}",
|
|
129
|
+
vars=lambda record, vars: vars.update(
|
|
130
|
+
{
|
|
131
|
+
"id": record.pid.pid_value,
|
|
132
|
+
"type": record.type.id,
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
links_search = pagination_links("{+api}/vocabularies/{type}{?args*}")
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class VocabularyTypesServiceConfig(RecordServiceConfig):
|
|
142
|
+
"""Vocabulary types service configuration."""
|
|
143
|
+
|
|
144
|
+
service_id = "vocabulary_types"
|
|
145
|
+
permission_policy_cls = PermissionPolicy
|
|
146
|
+
record_cls = VocabularyType
|
|
147
|
+
schema = VocabularySchema # Works but should be VocabularyTypeSchema if this is defined at some point
|
|
148
|
+
result_list_cls = results.VocabularyTypeList
|
|
149
|
+
|
|
150
|
+
links_item = {
|
|
151
|
+
"self": ConditionalLink(
|
|
152
|
+
cond=is_custom_vocabulary_type,
|
|
153
|
+
if_=Link(
|
|
154
|
+
"{+api}/{id}",
|
|
155
|
+
vars=lambda vocab_type, vars: vars.update({"id": vocab_type["id"]}),
|
|
156
|
+
),
|
|
157
|
+
else_=Link(
|
|
158
|
+
"{+api}/vocabularies/{id}",
|
|
159
|
+
vars=lambda vocab_type, vars: vars.update({"id": vocab_type["id"]}),
|
|
160
|
+
),
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
search = VocabularyTypeSearchOptions
|
|
165
|
+
|
|
166
|
+
components = [
|
|
167
|
+
# Order of components are important!
|
|
168
|
+
VocabularyTypeComponent,
|
|
169
|
+
DataComponent,
|
|
170
|
+
PIDComponent,
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
links_search = pagination_links("{+api}/vocabularies/{type}{?args*}")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2022-2024 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
+
|
|
8
|
+
"""Custom Fields for InvenioRDM."""
|
|
9
|
+
|
|
10
|
+
from .subject import SUBJECT_FIELDS, SUBJECT_FIELDS_UI
|
|
11
|
+
from .vocabulary import VocabularyCF
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"VocabularyCF",
|
|
15
|
+
"SUBJECT_FIELDS_UI",
|
|
16
|
+
"SUBJECT_FIELDS",
|
|
17
|
+
]
|