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

allow submitting system forms with a name for display to users #31923

Merged
merged 12 commits into from
Jul 25, 2022
2 changes: 1 addition & 1 deletion corehq/apps/hqcase/templates/hqcase/xml/case_block.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' ?>
<system version="1" uiVersion="1" xmlns="{{ xmlns }}" xmlns:orx="http://openrosa.org/jr/xforms">
<system version="1" uiVersion="1" xmlns="{{ xmlns }}" xmlns:orx="http://openrosa.org/jr/xforms"{% if name %} name="{{ name }}"{% endif %}>
{% if form_data %}
{% for name, value in form_data.items %}
<{{ name }}>{{ value }}</{{ name }}>
Expand Down
5 changes: 4 additions & 1 deletion corehq/apps/hqcase/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

def submit_case_blocks(case_blocks, domain, username="system", user_id=None,
xmlns=None, attachments=None, form_id=None,
submission_extras=None, case_db=None, device_id=None, max_wait=...):
submission_extras=None, case_db=None, device_id=None, form_name=None, max_wait=...):
"""
Submits casexml in a manner similar to how they would be submitted from a phone.

Expand All @@ -49,6 +49,8 @@ def submit_case_blocks(case_blocks, domain, username="system", user_id=None,
is posting cases to make it easier to trace the source. Used in combination with
XMLNS this allows pinpointing the exact source. Example: If the cases are being
generated by an Automatic Case Rule, then the device_id should be the rule's ID.
:param form_name: Human readable version of the device_id. For example the
Automatic Case Rule name.
Comment on lines +52 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

:param submission_extras: Dict of additional kwargs to pass through to ``SubmissionPost``
:param max_wait: Maximum time (in seconds) to allow the process to be delayed if
the project is over its submission rate limit.
Expand All @@ -64,6 +66,7 @@ def submit_case_blocks(case_blocks, domain, username="system", user_id=None,
form_id = form_id or uuid.uuid4().hex
form_xml = render_to_string('hqcase/xml/case_block.xml', {
'xmlns': xmlns or SYSTEM_FORM_XMLNS,
'name': form_name,
'case_block': case_blocks,
'time': now,
'uid': form_id,
Expand Down