Commit 31612956 authored by Viacheslav Sukhovieiev's avatar Viacheslav Sukhovieiev
Browse files

feat: add skip_field logic to export loop

parent f7533560
......@@ -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:
if filter_func is not None:
value = filter_func(field_name, value, context)
if value is ForbiddenRole:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment