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

Conversation

snopoke
Copy link
Contributor

@snopoke snopoke commented Jul 21, 2022

Product Description

In terms of product changes this will currently only impact case update rules which will now display on the UI with a human readable name.

Before this change the display would look like this:

image

Once this change get's deployed the following display options will exist:

Raw XMLNS
For any system form that does not have it's XMLNS mapped we will continue to display the XMLNS:

image

Human readable XMLNS name
This will apply to forms (old and new) that have their XMLNS mapped to a readable name

image

Human readable XMLNS name with details
Form that have their XMLNS mapped and also include a form name in the XML will be displayed as

image

Technical Summary

Update submit_case_blocks to include a form_name kwarg which is used to add a name attribute to the root XML element of the form.

Updates to the display code that converts a form XMLNS to a human readable name to include this value if it is present.

Note for future work:
There is lots of work that can still be done to clean up other system forms in order to use the best practices layed out in #31873.

There could also be future work to create smarter display output for forms e.g. link to the actual update rule etc.

Safety Assurance

Safety story

Areas of impact:

  • any system form submissions
    • these should be covered by their own unit tests
  • display of forms in reports etc
    • tests added for the changes
    • also tested locally

Automated test coverage

I've added some tests for the display utils. I'm wondering if it's worth adding tests for submit_case_blocks but I don't really think so.

QA Plan

None

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@snopoke snopoke added the product/all-users-all-environments Change impacts all users on all environments label Jul 21, 2022
@snopoke snopoke requested a review from esoergel as a code owner July 21, 2022 14:29
Copy link
Contributor

@esoergel esoergel left a comment

Choose a reason for hiding this comment

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

🚀
Very cool, I'm excited to hear what delivery thinks of it!

Comment on lines +52 to +53
:param form_name: Human readable version of the device_id. For example the
Automatic Case Rule name.
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@@ -88,39 +88,49 @@ def __init__(self, domain, xmlns, app_id):
def get_label(self, lang=None, separator=None):
if separator is None:
separator = " > "

return (
Copy link
Contributor

Choose a reason for hiding this comment

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

?w=1 reads a lot easier for this commit

@@ -187,12 +187,13 @@ def get_case_history(case):

changes = defaultdict(dict)
for form in XFormInstance.objects.get_forms(case.xform_ids, case.domain):
name = xmlns_to_name(case.domain, form.xmlns, form.app_id, form_name=form.form_data.get('@name'))
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make sense to just pass the whole form to xmlns_to_name and extract what's needed from it there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I guess in some instances it's an unwrapped form. Maybe not then.

Copy link
Contributor Author

@snopoke snopoke Jul 25, 2022

Choose a reason for hiding this comment

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

Yea, this also get's used for things like export configs which only have an app_id and xmlns. But it could be useful to create a wrapper function that takes the whole form.

@snopoke snopoke merged commit 419d326 into master Jul 25, 2022
@snopoke snopoke deleted the sk/add-name branch July 25, 2022 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/all-users-all-environments Change impacts all users on all environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants