Skip to content

Commit

Permalink
Update choices in survey level for merged xforms
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanga committed Feb 23, 2025
1 parent 899ae7f commit 11d1952
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion onadata/libs/serializers/merged_xform_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_merged_xform_survey(xforms):
del child["bind"]

# merge select one and select multiple options
if "children" in child and child["type"] in SELECTS:
if child["type"] in SELECTS:
children = []
for xform_dict in xform_dicts:
element_list = _list_with_name(child["name"], xform_dict["children"])
Expand All @@ -99,6 +99,7 @@ def get_merged_xform_survey(xforms):
# remove duplicates
set_of_jsons = {json.dumps(d, sort_keys=True) for d in children}
child["children"] = [json.loads(t) for t in set_of_jsons]
merged_xform_dict["choices"][child["itemset"]] = child["children"]

if is_empty:
raise serializers.ValidationError(_("No matching fields in xforms."))
Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/utils/chart_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_field_choices(field, xform):
if isinstance(field, str):
return choices.get(field)
if hasattr(field, "name") and field.name in choices:
return choices.get(field.name)
return choices.get(field.name).options
if hasattr(field, "itemset"):
return choices.get(field.itemset).options

Expand Down

0 comments on commit 11d1952

Please sign in to comment.