Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
prozorro-sale
Schematics
Commits
31612956
Commit
31612956
authored
Sep 30, 2022
by
Viacheslav Sukhovieiev
Browse files
feat: add skip_field logic to export loop
parent
f7533560
Changes
1
Hide whitespace changes
Inline
Side-by-side
schematics/transforms.py
View file @
31612956
...
...
@@ -234,7 +234,7 @@ def _mutate(schema, mutable, raw_data, context):
def
export_loop
(
schema
,
instance_or_dict
,
field_converter
=
None
,
role
=
None
,
raise_error_on_role
=
True
,
export_level
=
None
,
app_data
=
None
,
context
=
None
):
export_level
=
None
,
app_data
=
None
,
context
=
None
,
skip_fields
=
None
):
"""
The export_loop function is intended to be a general loop definition that
can be used for any form of data shaping, such as application of roles or
...
...
@@ -292,10 +292,15 @@ def export_loop(schema, instance_or_dict, field_converter=None, role=None, raise
if
isinstance
(
instance_or_dict
,
models
.
Model
):
instance_or_dict
=
instance_or_dict
.
_Model__data
fields_to_skip
=
skip_fields
if
skip_fields
is
not
None
else
[]
for
field_name
,
field
,
value
in
atoms
(
schema
,
instance_or_dict
):
serialized_name
=
field
.
serialized_name
or
field_name
if
serialized_name
in
fields_to_skip
:
continue
if
filter_func
is
not
None
:
value
=
filter_func
(
field_name
,
value
,
context
)
if
value
is
ForbiddenRole
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment