Skip to content

Commit

Permalink
Tag release v2.3.7 (#1867)
Browse files Browse the repository at this point in the history
* Bump version to v2.3.7
* Fix duplicate records after edit (#1869)
* Update CHANGES.rst
  • Loading branch information
DavisRayM authored Aug 11, 2020
1 parent d267875 commit 81a8df2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
16 changes: 16 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ Changelog for Onadata

``* represents releases that introduce new migrations``

v2.3.7(2020-08-11)
------------------

- Add a way to elongate `ODKToken` expiry data *
`PR #1847 <https://github.com/onaio/onadata/pull/1847>`_
[@DavisRayM]
- Set the correct root node for created submissions
`PR #1853 <https://github.com/onaio/onadata/pull/1853>`_
[@DavisRayM]
- Ensure only XForm admins & managers can review submissions
`PR #1864 <https://github.com/onaio/onadata/pull/1864>`_
[@DavisRayM]
- Stop duplication of RapidPro submissions on edit
`PR #1869 <https://github.com/onaio/onadata/pull/1869>`_
[@DavisRayM]

v2.3.6(2020-07-29)
------------------

Expand Down
2 changes: 1 addition & 1 deletion onadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from __future__ import absolute_import, unicode_literals

__version__ = "2.3.6"
__version__ = "2.3.7"


# This will make sure the app is always imported when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ def test_rapidpro_post_submission(self):
expected_xml = (
f"<?xml version='1.0' ?><{self.xform.survey.name} id="
"'transportation_2011_07_25'><fruit_name>orange"
f"</fruit_name></{self.xform.survey.name}>")
f"</fruit_name>\n<meta>\n <instanceID>uuid:{uuid}"
f"</instanceID>\n</meta></{self.xform.survey.name}>")
self.assertEqual(instance.xml, expected_xml)
self.assertEqual(self.xform.survey.name, 'data')

Expand Down
11 changes: 7 additions & 4 deletions onadata/libs/serializers/data_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def get_request_and_username(context):
return (request, username)


def create_submission(request, username, data_dict, xform_id):
def create_submission(
request, username, data_dict, xform_id, gen_uuid: bool = False):
"""
Returns validated data object instances
"""
xml_string = dict2xform(
data_dict, xform_id, username=username)
data_dict, xform_id, username=username, gen_uuid=gen_uuid)
xml_file = BytesIO(xml_string.encode('utf-8'))

error, instance = safe_create_instance(username, xml_file, [], None,
Expand Down Expand Up @@ -334,7 +335,8 @@ def create(self, validated_data):
request, username = get_request_and_username(self.context)
rapidpro_dict = query_list_to_dict(request.data.get('values'))
instance = create_submission(request, username, rapidpro_dict,
validated_data['id_string'])
validated_data['id_string'],
gen_uuid=True)

return instance

Expand All @@ -352,7 +354,8 @@ def create(self, validated_data):
instance_data_dict = {
k: post_data[k].get('value') for k in post_data.keys()}
instance = create_submission(
request, username, instance_data_dict, validated_data['id_string'])
request, username, instance_data_dict,
validated_data['id_string'], gen_uuid=True)
return instance


Expand Down
4 changes: 2 additions & 2 deletions onadata/libs/utils/common_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def get_boolean_value(str_var, default=None):
return str_var if default else False


def get_uuid():
def get_uuid(hex_only: bool = True):
'''
Return UUID4 hex value
'''
return uuid.uuid4().hex
return uuid.uuid4().hex if hex_only else str(uuid.uuid4())


def report_exception(subject, info, exc_info=None):
Expand Down
9 changes: 7 additions & 2 deletions onadata/libs/utils/logger_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from onadata.apps.viewer.models.parsed_instance import ParsedInstance
from onadata.apps.viewer.signals import process_submission
from onadata.libs.utils.common_tags import METADATA_FIELDS
from onadata.libs.utils.common_tools import report_exception
from onadata.libs.utils.common_tools import report_exception, get_uuid
from onadata.libs.utils.model_tools import set_uuid
from onadata.libs.utils.user_auth import get_user_default_project

Expand Down Expand Up @@ -112,7 +112,7 @@ def _get_instance(xml, new_uuid, submitted_by, status, xform, checksum):
return instance


def dict2xform(jsform, form_id, root=None, username=None):
def dict2xform(jsform, form_id, root=None, username=None, gen_uuid=False):
"""
Converts a dictionary containing submission data into an XML
Submission for the appropriate form.
Expand Down Expand Up @@ -143,6 +143,11 @@ def dict2xform(jsform, form_id, root=None, username=None):
else:
root = 'data'

if gen_uuid:
jsform['meta'] = {
'instanceID': 'uuid:' + get_uuid(hex_only=False)
}

return "<?xml version='1.0' ?><{0} id='{1}'>{2}</{0}>".format(
root, form_id, dict2xml(jsform))

Expand Down

0 comments on commit 81a8df2

Please sign in to comment.