Skip to content

Commit

Permalink
Change SELECT_ONE and SELECT_MULTIPLE bind type
Browse files Browse the repository at this point in the history
Change SELECT_ONE and SELECT_MULTIPLE bind type to 'string'. More
Info: XLSForm/pyxform#410
  • Loading branch information
DavisRayM committed Feb 25, 2020
1 parent 3543b56 commit 2ec2322
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions onadata/libs/utils/export_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@
from onadata.apps.viewer.models.data_dictionary import DataDictionary
from onadata.libs.utils.common_tags import (
ATTACHMENTS, BAMBOO_DATASET_ID, DELETEDAT, DURATION, GEOLOCATION,
ID, INDEX, MULTIPLE_SELECT_TYPE, NOTES, PARENT_INDEX,
ID, INDEX, MULTIPLE_SELECT_TYPE, SELECT_ONE, NOTES, PARENT_INDEX,
PARENT_TABLE_NAME, REPEAT_INDEX_TAGS, SAV_255_BYTES_TYPE,
SAV_NUMERIC_TYPE, STATUS, SUBMISSION_TIME, SUBMITTED_BY, TAGS, UUID,
VERSION, XFORM_ID_STRING, REVIEW_STATUS, REVIEW_COMMENT)
from onadata.libs.utils.mongo import _decode_from_mongo, _is_invalid_for_mongo

# the bind type of select multiples that we use to compare
MULTIPLE_SELECT_BIND_TYPE = 'select'
SELECT_ONE_BIND_TYPE = 'select1'
SELECT_BIND_TYPE = 'string'
GEOPOINT_BIND_TYPE = 'geopoint'
OSM_BIND_TYPE = 'osm'
DEFAULT_UPDATE_BATCH = 100
Expand Down Expand Up @@ -475,7 +474,8 @@ def build_sections(
{child_xpath: _encode_for_mongo(child_xpath)})

# if its a select multiple, make columns out of its choices
if child.bind.get('type') == MULTIPLE_SELECT_BIND_TYPE:
if child.bind.get('type') == SELECT_BIND_TYPE \
and child.type == MULTIPLE_SELECT_TYPE:
choices = []
if self.SPLIT_SELECT_MULTIPLES:
choices = self._get_select_mulitples_choices(
Expand Down Expand Up @@ -527,7 +527,8 @@ def build_sections(
_append_xpaths_to_section(
current_section_name, osm_fields,
child.get_abbreviated_xpath(), xpaths)
if child.bind.get(u"type") == SELECT_ONE_BIND_TYPE:
if child.bind.get(u"type") == SELECT_BIND_TYPE \
and child.type == SELECT_ONE:
_append_xpaths_to_section(
current_section_name, select_ones,
child.get_abbreviated_xpath(), [])
Expand Down Expand Up @@ -1062,7 +1063,7 @@ def _is_numeric(xpath, element_type, data_dictionary):
parent_xpath = '/'.join(xpath.split('/')[:-1])
parent = data_dictionary.get_element(parent_xpath)
return (parent and parent.type == MULTIPLE_SELECT_TYPE)
elif element_type != SELECT_ONE_BIND_TYPE:
elif element_type != SELECT_BIND_TYPE:
return False

if var_name not in all_value_labels:
Expand Down

0 comments on commit 2ec2322

Please sign in to comment.