Skip to content

Commit

Permalink
Merge branch 'main' into stojanovic/fe-108-find-a-component-for-dates
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekys authored Nov 28, 2023
2 parents b3c7081 + 3b8a656 commit 1d293f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion oarepo_ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def dump_empty(schema_or_field):
return []
if isinstance(schema_or_field, (NestedAttribute, fields.Nested)):
field = schema_or_field
return dump_empty(field.nested)
nested_schema = field.nested
if callable(nested_schema):
nested_schema = nested_schema()
return dump_empty(nested_schema)
if isinstance(schema_or_field, fields.Str):
return ""

Expand Down
2 changes: 2 additions & 0 deletions tests/test_dump_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SimpleMetadataSchema(ma.Schema):
simple_arr = ma.fields.List(ma.fields.String())
object_arr = ma.fields.List(ma.fields.Nested(NestedSchema))
nested_obj = ma.fields.Nested(NestedSchema)
nested_via_func = ma.fields.Nested(lambda: NestedSchema())

class Meta:
unknown = ma.INCLUDE
Expand Down Expand Up @@ -57,6 +58,7 @@ def test_empty_dump():
"links": None,
"metadata": {
"nested_obj": {"count": None, "title": "", "valid": None},
"nested_via_func": {"count": None, "title": "", "valid": None},
"object_arr": [],
"simple_arr": [],
"title": "",
Expand Down

0 comments on commit 1d293f8

Please sign in to comment.