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

Use Django forms to sanitize and validate prepaid search parameters #6083

Merged
merged 2 commits into from
Oct 22, 2020

Conversation

willbarton
Copy link
Member

@willbarton willbarton commented Oct 22, 2020

This change uses Django forms to validate and sanitize the prepaid agreements search parameters.

It adds two forms. SearchForm and FilterForm that handle the search fields and the filter fields, respectively. These are two separate forms because the filter choices depend on the results from the search.

At present this does not present any information to users on the validity of the form submission — default results will be returned for search if the search query, field, or results page number are not valid; the default filter selection (i.e. no filters) will be returned if any filter option is invalid.

The motivation for this change is to prevent a 500 error on invalid filters.

This change also removes the PREPAID_AGREEMENTS_SEARCH feature flag.

How to test this PR

Compare the results from a search that includes a null character as part of a filter option between beta and localhost (or our dev Docker cluster):

Note that the request to beta produces a 500 error, where localhost does not.

Run the Cypress prepaid agreements tests (yarn run cypress open) to confirm that general behavior is as expected, and/or compare general search and filter option selection between beta and localhost (or our dev Docker cluster):

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code follows the standards laid out in the CFPB development guidelines

The prepaid search feature flag has been turned on in production for over a year. This changes removes the feature flag.
This change uses Django forms to validate and sanitize the prepaid agreements search parameters.

It adds two forms. `SearchForm` and `FilterForm` that handle the search fields and the filter fields, respectively. These are two separate forms because the filter choices depend on the results from the search.
Copy link
Contributor

@cwdavies cwdavies left a comment

Choose a reason for hiding this comment

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

@willbarton willbarton merged commit 7a1a783 into main Oct 22, 2020
@willbarton willbarton deleted the prepaid_form branch October 22, 2020 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants