Skip to content

Commit

Permalink
Merge pull request #1193
Browse files Browse the repository at this point in the history
Do not split select multiple in repeats if False
  • Loading branch information
ukanga authored Dec 21, 2017
2 parents 76cd5a1 + fb480a5 commit f4a99ab
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 168 deletions.
7 changes: 5 additions & 2 deletions onadata/apps/logger/models/xform.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,18 +300,21 @@ def get_survey_element(self, name_or_xpath):

return fields[0] if len(fields) else None

def get_child_elements(self, name_or_xpath):
def get_child_elements(self, name_or_xpath, split_select_multiples=True):
"""Returns a list of survey elements children in a flat list.
If the element is a group or multiple select the child elements are
appended to the list. If the name_or_xpath is a repeat we iterate
through the child elements as well.
"""
GROUP_AND_SELECT_MULTIPLES = ['group']
if split_select_multiples:
GROUP_AND_SELECT_MULTIPLES += ['select all that apply']

def flatten(elem, items=[]):
results = []
if elem:
xpath = elem.get_abbreviated_xpath()
if elem.type in ['group', 'select all that apply'] or \
if elem.type in GROUP_AND_SELECT_MULTIPLES or \
(xpath == name_or_xpath and elem.type == 'repeat'):
for child in elem.children:
results += flatten(child)
Expand Down
Loading

0 comments on commit f4a99ab

Please sign in to comment.