-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6083 from cfpb/prepaid_form
Use Django forms to sanitize and validate prepaid search parameters
- Loading branch information
Showing
5 changed files
with
145 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from django import forms | ||
|
||
|
||
class SearchForm(forms.Form): | ||
"""Django form to validate the basic prepaid search fields""" | ||
page = forms.IntegerField(required=False) | ||
q = forms.CharField(required=False) | ||
search_field = forms.ChoiceField( | ||
choices=[ | ||
('all', 'All fields'), | ||
('name', 'Product name'), | ||
('program_manager', 'Program manager'), | ||
('other_relevant_parties', 'Other relevant party') | ||
], | ||
required=False, | ||
) | ||
|
||
|
||
class FilterForm(forms.Form): | ||
"""Django form to validate the prepaid search filter fields""" | ||
issuer_name = forms.MultipleChoiceField( | ||
choices=[], | ||
required=False | ||
) | ||
prepaid_type = forms.MultipleChoiceField( | ||
choices=[], | ||
required=False | ||
) | ||
status = forms.MultipleChoiceField( | ||
choices=[], | ||
required=False | ||
) | ||
|
||
def set_issuer_name_choices(self, choices): | ||
self.fields['issuer_name'].choices = [(c, c) for c in choices] | ||
|
||
def set_prepaid_type_choices(self, choices): | ||
self.fields['prepaid_type'].choices = [(c, c) for c in choices] | ||
|
||
def set_status_choices(self, choices): | ||
self.fields['status'].choices = [(c, c) for c in choices] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters