-
Notifications
You must be signed in to change notification settings - Fork 132
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
Set root node for created submissions to the XForms configured root node #1853
Conversation
0b9e462
to
4bb6562
Compare
4bb6562
to
acf673d
Compare
@@ -46,7 +46,7 @@ def create_submission(request, username, data_dict, xform_id): | |||
""" | |||
Returns validated data object instances | |||
""" | |||
xml_string = dict2xform(data_dict, xform_id) | |||
xml_string = dict2xform(data_dict, xform_id, root='data') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to older forms that still use the filename of the XLSForm that is in our historical data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's something I did not initially consider... I'll look into retrieving the root node name from the form. I believe pyxform provides this information on the survey object, I'll confirm and update the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR. Now trying to retrieve the root node name from the XForm
if a username is passed alongside the form_id
, This should ensure all new submissions have the correct root node for the form.
54ac36c
to
5eaee15
Compare
5eaee15
to
e87e511
Compare
By default XLSForms set the default node to 'data'
e87e511
to
a2b9698
Compare
@DavisRayM New RapidPro submissions can now be edited in Enketo whereas old submissions cannot. The attached error is returned when editing old RapidPro submissions. |
34523fd
to
8ff96fe
Compare
Old submissions from RapidPro will have to be updated via the management command
|
8ff96fe
to
997d01f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me but might require @ukanga 's eyes as well
initial_xml = inst.xml | ||
form_id = re.escape(inst.xform.id_string) | ||
if not root: | ||
root = inst.xform.survey.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the value of root
always be data
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not always, it'll be data
as long as the user doesn't configure the form to have another root node name.
997d01f
to
46dc1a3
Compare
Here is an overview of what got changed by this pull request: Complexity increasing per file
==============================
- onadata/apps/logger/management/commands/replace_form_id_root_node.py 4
See the complete overview on Codacy |
Changes / Features implemented
Set the root node to
data
. By default the root node of an XForm is always set todata
unless specifically set to something elseMake change backward compatible with forms that have the root node name set to something else other than the default(
data
)Add management command that helps replace the XForm ID String as the root node for Instances
Steps taken to verify this change does what is intended
Things to Note
Submissions made using RapidPro before the changes in this PR are in effect, will still have the
different root node name
issue. Suggestion: Those submissions should be updated manually on a case by case basis(Server wide submission XML edits seem a bit too unsafe)