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

Upgrade PyXForm dependency to v1.1.0 #1796

Merged
merged 9 commits into from
Mar 27, 2020
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
80 changes: 40 additions & 40 deletions onadata/apps/api/tests/fixtures/Transportation Form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>transportation_2011_07_25</h:title>
<model>
<model odk:xforms-version="1.0.0">
<instance>
<transportation id="transportation_2011_07_25" version="20141112071722">
<data id="transportation_2011_07_25" version="20141112071722">
<formhub>
<uuid/>
</formhub>
Expand Down Expand Up @@ -45,28 +45,28 @@
<meta>
<instanceID/>
</meta>
</transportation>
</data>
</instance>
<bind nodeset="/transportation/transport/available_transportation_types_to_referral_facility" type="select"/>
<bind nodeset="/transportation/transport/available_transportation_types_to_referral_facility_other" relevant="selected(../available_transportation_types_to_referral_facility, 'other')" type="string"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/ambulance/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'ambulance')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/bicycle/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'bicycle')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/boat_canoe/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'boat_canoe')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/bus/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'bus')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/donkey_mule_cart/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'donkey_mule_cart')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/keke_pepe/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'keke_pepe')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/lorry/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'lorry')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/motorbike/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'motorbike')" type="select1"/>
<bind nodeset="/transportation/transport/loop_over_transport_types_frequency/taxi/frequency_to_referral_facility" relevant="selected( /transportation/transport/available_transportation_types_to_referral_facility , 'taxi')" type="select1"/>
<bind nodeset="/transportation/image1" type="binary"/>
<bind jr:preload="uid" nodeset="/transportation/meta/instanceID" readonly="true()" type="string"/>
<bind calculate="'%(form_uuid)s'" nodeset="/transportation/formhub/uuid" type="string"/>
<bind nodeset="/data/transport/available_transportation_types_to_referral_facility" type="string"/>
<bind nodeset="/data/transport/available_transportation_types_to_referral_facility_other" relevant="selected(../available_transportation_types_to_referral_facility, 'other')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/ambulance/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'ambulance')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/bicycle/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'bicycle')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/boat_canoe/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'boat_canoe')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/bus/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'bus')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/donkey_mule_cart/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'donkey_mule_cart')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/keke_pepe/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'keke_pepe')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/lorry/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'lorry')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/motorbike/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'motorbike')" type="string"/>
<bind nodeset="/data/transport/loop_over_transport_types_frequency/taxi/frequency_to_referral_facility" relevant="selected( /data/transport/available_transportation_types_to_referral_facility , 'taxi')" type="string"/>
<bind nodeset="/data/image1" type="binary"/>
<bind jr:preload="uid" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
<bind calculate="'%(form_uuid)s'" nodeset="/data/formhub/uuid" type="string"/>
</model>
</h:head>
<h:body>
<group ref="/transportation/transport">
<group ref="/data/transport">
<label>Transportation</label>
<select ref="/transportation/transport/available_transportation_types_to_referral_facility">
<select ref="/data/transport/available_transportation_types_to_referral_facility">
<label>What types of transportation are available from here to the referral health facility?</label>
<item>
<label>ambulance</label>
Expand Down Expand Up @@ -109,13 +109,13 @@
<value>other</value>
</item>
</select>
<input ref="/transportation/transport/available_transportation_types_to_referral_facility_other">
<input ref="/data/transport/available_transportation_types_to_referral_facility_other">
<label>Specify other.</label>
</input>
<group ref="/transportation/transport/loop_over_transport_types_frequency">
<group ref="/transportation/transport/loop_over_transport_types_frequency/ambulance">
<group ref="/data/transport/loop_over_transport_types_frequency">
<group ref="/data/transport/loop_over_transport_types_frequency/ambulance">
<label>ambulance</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/ambulance/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/ambulance/frequency_to_referral_facility">
<label>Is ambulance available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -135,9 +135,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/bicycle">
<group ref="/data/transport/loop_over_transport_types_frequency/bicycle">
<label>bicycle</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/bicycle/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/bicycle/frequency_to_referral_facility">
<label>Is bicycle available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -157,9 +157,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/boat_canoe">
<group ref="/data/transport/loop_over_transport_types_frequency/boat_canoe">
<label>boat/canoe</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/boat_canoe/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/boat_canoe/frequency_to_referral_facility">
<label>Is boat/canoe available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -179,9 +179,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/bus">
<group ref="/data/transport/loop_over_transport_types_frequency/bus">
<label>bus</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/bus/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/bus/frequency_to_referral_facility">
<label>Is bus available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -201,9 +201,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/donkey_mule_cart">
<group ref="/data/transport/loop_over_transport_types_frequency/donkey_mule_cart">
<label>donkey/mule/cart</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/donkey_mule_cart/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/donkey_mule_cart/frequency_to_referral_facility">
<label>Is donkey/mule/cart available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -223,9 +223,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/keke_pepe">
<group ref="/data/transport/loop_over_transport_types_frequency/keke_pepe">
<label>keke napep</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/keke_pepe/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/keke_pepe/frequency_to_referral_facility">
<label>Is keke napep available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -245,9 +245,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/lorry">
<group ref="/data/transport/loop_over_transport_types_frequency/lorry">
<label>lorry</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/lorry/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/lorry/frequency_to_referral_facility">
<label>Is lorry available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -267,9 +267,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/motorbike">
<group ref="/data/transport/loop_over_transport_types_frequency/motorbike">
<label>motorbike</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/motorbike/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/motorbike/frequency_to_referral_facility">
<label>Is motorbike available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -289,9 +289,9 @@
</item>
</select1>
</group>
<group ref="/transportation/transport/loop_over_transport_types_frequency/taxi">
<group ref="/data/transport/loop_over_transport_types_frequency/taxi">
<label>taxi</label>
<select1 ref="/transportation/transport/loop_over_transport_types_frequency/taxi/frequency_to_referral_facility">
<select1 ref="/data/transport/loop_over_transport_types_frequency/taxi/frequency_to_referral_facility">
<label>Is taxi available daily or weekly?</label>
<item>
<label>Daily</label>
Expand All @@ -313,7 +313,7 @@
</group>
</group>
</group>
<upload mediatype="image/*" ref="/transportation/image1">
<upload mediatype="image/*" ref="/data/image1">
<label>Photo</label>
</upload>
</h:body>
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/api/tests/viewsets/test_dataview_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_get_dataview_form_definition(self):
self._create_dataview()

data = {
"name": "tutorial",
"name": "data",
"title": "tutorial",
"default_language": "default",
"id_string": "tutorial",
Expand Down
18 changes: 11 additions & 7 deletions onadata/apps/api/tests/viewsets/test_xform_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def test_form_format(self):
})
formid = self.xform.pk
data = {
"name": "transportation",
"name": "data",
"title": "transportation_2011_07_25",
"default_language": "default",
"id_string": "transportation_2011_07_25",
Expand Down Expand Up @@ -634,7 +634,7 @@ def test_form_format(self):
uuid_nodes = [
node for node in model_node.childNodes
if node.nodeType == Node.ELEMENT_NODE and
node.getAttribute("nodeset") == "/transportation/formhub/uuid"]
node.getAttribute("nodeset") == "/data/formhub/uuid"]
self.assertEqual(len(uuid_nodes), 1)
uuid_node = uuid_nodes[0]
uuid_node.setAttribute("calculate", "''")
Expand Down Expand Up @@ -1381,8 +1381,12 @@ def test_publish_invalid_xls_form(self):
response = view(request)
self.assertEqual(response.status_code, 400)
self.assertEqual(response.get('Cache-Control'), None)
error_msg = 'In strict mode, the XForm ID must be a valid slug'\
' and contain no spaces.'
error_msg = ('In strict mode, the XForm ID must be '
'a valid slug and contain no spaces.'
' Please ensure that you have set an'
' id_string in the settings sheet or '
'have modified the filename to not '
'contain any spaces.')
self.assertEqual(response.data.get('text'), error_msg)

path = os.path.join(
Expand Down Expand Up @@ -2196,7 +2200,7 @@ def test_manager_can_update_xform_xls_file(self):
fhuuid = xml.find('formhub/uuid')
self.assertEqual(
xml[xml[:fhuuid].rfind('=') + 2:fhuuid],
'/transportation/'
'/data/'
)

view = XFormViewSet.as_view({
Expand Down Expand Up @@ -2233,7 +2237,7 @@ def test_manager_can_update_xform_xls_file(self):
fhuuid = xml.find('formhub/uuid')
self.assertEqual(
xml[xml[:fhuuid].rfind('=') + 2:fhuuid],
'/transportation/'
'/data/'
)

def test_update_xform_with_different_id_string_form_with_sub(self):
Expand Down Expand Up @@ -2342,7 +2346,7 @@ def test_update_xform_xls_file_with_different_model_name(self):
response = view(request, pk=form_id)
self.assertEqual(response.status_code, 200)
xform = XForm.objects.get(pk=form_id)
self.assertEqual('transportation',
self.assertEqual('data',
xform.survey.xml_instance().tagName)

def test_id_strings_should_be_unique_in_each_account(self):
Expand Down
15 changes: 10 additions & 5 deletions onadata/apps/logger/models/xform.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
NOTES, SUBMISSION_TIME,
SUBMITTED_BY, TAGS, TOTAL_MEDIA,
UUID, VERSION, REVIEW_STATUS,
REVIEW_COMMENT)
REVIEW_COMMENT,
MULTIPLE_SELECT_TYPE)
from onadata.libs.utils.model_tools import queryset_iterator
from onadata.libs.utils.mongo import _encode_for_mongo

Expand Down Expand Up @@ -163,7 +164,8 @@ def check_version_set(survey):


def _expand_select_all_that_apply(d, key, e):
if e and e.bind.get(u"type") == u"select":
if e and e.bind.get(u"type") == u"string"\
and e.type == MULTIPLE_SELECT_TYPE:
options_selected = d[key].split()
for child in e.children:
new_key = child.get_abbreviated_xpath()
Expand Down Expand Up @@ -437,7 +439,8 @@ def xpaths(self,

# replace the single question column with a column for each
# item in a select all that apply question.
if survey_element.bind.get(u'type') == u'select':
if survey_element.bind.get(u'type') == u'string' \
and survey_element.type == MULTIPLE_SELECT_TYPE:
result.pop()
for child in survey_element.children:
result.append('/'.join([path, child.name]))
Expand Down Expand Up @@ -475,7 +478,6 @@ def get_headers(self, include_additional_headers=False):
"""
Return a list of headers for a csv file.
"""

def shorten(xpath):
xpath_list = xpath.split('/')
return '/'.join(xpath_list[2:])
Expand Down Expand Up @@ -863,7 +865,10 @@ def save(self, *args, **kwargs):
not re.search(r"^[\w-]+$", self.id_string):
raise XLSFormError(
_(u'In strict mode, the XForm ID must be a '
'valid slug and contain no spaces.'))
'valid slug and contain no spaces. Please ensure'
' that you have set an id_string in the settings sheet '
'or have modified the filename to not contain'
' any spaces.'))

if not self.sms_id_string and (update_fields is None or
'id_string' in update_fields):
Expand Down
Binary file not shown.
Binary file not shown.
Loading