From d103393acb6a80c7c10b43cc673897e9a26d7693 Mon Sep 17 00:00:00 2001 From: Alex Ioannidis Date: Thu, 11 Jul 2024 21:43:59 +0200 Subject: [PATCH] global: remove dependency on invenio-vocabularies * Removes the dependency from invenio-vocabularies. * Delegates administration UI schema type definition to the mashmallow class. --- invenio_administration/marshmallow_utils.py | 22 +++++---------------- setup.cfg | 1 - 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/invenio_administration/marshmallow_utils.py b/invenio_administration/marshmallow_utils.py index c25fb2b..958c4ea 100644 --- a/invenio_administration/marshmallow_utils.py +++ b/invenio_administration/marshmallow_utils.py @@ -8,21 +8,10 @@ """Invenio administration marshmallow utils module.""" -from invenio_vocabularies.services.schema import ( - BaseVocabularySchema, - ContribVocabularyRelationSchema, - VocabularyRelationSchema, -) from marshmallow import fields from marshmallow_utils import fields as invenio_fields from marshmallow_utils.fields import EDTFDateString, EDTFDateTimeString -vocabulary_schemas = [ - ContribVocabularyRelationSchema, - BaseVocabularySchema, - VocabularyRelationSchema, -] - custom_mapping = { # marshmallow fields.Str: "string", @@ -118,11 +107,7 @@ def jsonify_schema(schema): } if nested_field: - if any([isinstance(field_type.schema, x) for x in vocabulary_schemas]): - schema_type = "vocabulary" - else: - schema_type = "object" - + schema_type = getattr(field_type.schema, "administration_schema_type", "object") schema_dict[field].update( { "type": schema_type, @@ -131,11 +116,14 @@ def jsonify_schema(schema): ) elif list_field and isinstance(field_type.inner, fields.Nested): # list of objects (vocabularies or nested) + schema_type = getattr( + field_type.inner.schema, "administration_schema_type", "object" + ) schema_dict[field].update( { "type": "array", "items": { - "type": "object", + "type": schema_type, "properties": jsonify_schema(field_type.inner.schema), }, } diff --git a/setup.cfg b/setup.cfg index fbb72a8..da01215 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,6 @@ install_requires = invenio-accounts>=5.0.0,<6.0.0 invenio-base>=1.3.0,<2.0.0 invenio-db[postgresql,mysql]>=1.0.9,<2.0.0 - invenio-vocabularies>=4.0.0,<5.0.0 invenio-records-resources>=6.0.0,<7.0.0 invenio-search-ui>=2.1.2,<3.0.0 invenio-theme>=3.0.0,<4.0.0