Skip to content

Commit

Permalink
global: remove dependency on invenio-vocabularies
Browse files Browse the repository at this point in the history
* Removes the dependency from invenio-vocabularies.
* Delegates administration UI schema type definition to the mashmallow
  class.
  • Loading branch information
slint committed Jul 12, 2024
1 parent 1faf326 commit d103393
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
22 changes: 5 additions & 17 deletions invenio_administration/marshmallow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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),
},
}
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d103393

Please sign in to comment.