Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not split select multiple in repeats if False #1193

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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