Skip to content

Commit

Permalink
Ensure consistency of flex_options
Browse files Browse the repository at this point in the history
  • Loading branch information
soroush-tabesh committed Sep 15, 2021
1 parent 4da9f68 commit 8d4d746
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions rest_flex_fields/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ def __init__(self, *args, **kwargs):
self.expanded_fields = []
self._flex_fields_rep_applied = False

self._flex_options_all = {
"expand": (
expand
if len(expand) > 0
else self._get_permitted_expands_from_query_param(EXPAND_PARAM)
),
"fields": (fields if len(fields) > 0 else self._get_query_param_value(FIELDS_PARAM)),
"omit": omit if len(omit) > 0 else self._get_query_param_value(OMIT_PARAM),
}
self._flex_options_base = {
"expand": expand,
"fields": fields,
Expand All @@ -60,7 +51,11 @@ def __init__(self, *args, **kwargs):
if not omit else
[]),
}
# todo solve conflicts
self._flex_options_all = {
"expand": self._flex_options_base["expand"] + self._flex_options_rep_only["expand"],
"fields": self._flex_options_base["fields"] + self._flex_options_rep_only["fields"],
"omit": self._flex_options_base["omit"] + self._flex_options_rep_only["omit"],
}

def to_representation(self, instance):
if not self._flex_fields_rep_applied:
Expand Down

0 comments on commit 8d4d746

Please sign in to comment.