Use Django forms to sanitize and validate prepaid search parameters #6083
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change uses Django forms to validate and sanitize the prepaid agreements search parameters.
It adds two forms.
SearchForm
andFilterForm
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