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

Django form to capture user's EligibilityVerifier selection #322

Closed
5 tasks done
Tracked by #317
thekaveman opened this issue Mar 16, 2022 · 1 comment · Fixed by #337
Closed
5 tasks done
Tracked by #317

Django form to capture user's EligibilityVerifier selection #322

thekaveman opened this issue Mar 16, 2022 · 1 comment · Fixed by #337
Assignees

Comments

@thekaveman
Copy link
Member

thekaveman commented Mar 16, 2022

Background

Building on #320 and #332, once a TransitAgency has multiple EligibilityVerifier references, the user needs a way to select which one they will use for verification.

Django has the ChoiceField which can use the widget=RadioSelect to render as a list of radio buttons. The field takes a list of choices, each a tuple where the first item is the value and the second is the label:

from django import forms

choices = [("value1", "Label One"), ("value2", "Label Two")]
field = forms.ChoiceField(choices=choices, widget=forms.RadioSelect)

See e.g. https://stackoverflow.com/a/5925240/453168

Tasks

  • Create a new form class like EligibilityVerifierSelectionForm in benefits/eligibility/forms.py; form should POST to eligibility:index
  • Add a ChoiceField using widget=RadioSelect
  • Create an __init__() method accepting an agency parameter
  • Seed the ChoiceField.choices from the agency.eligibility_verifiers property, using the above choices structure as an example
  • Rework the eligibility:index view to handle both GET and POST
    • for GET: If agency has multiple verifiers, initialize form with the selected agency's verifiers and send to the template; otherwise store the one verifier in session and immediately redirect to eligibility:start
    • for POST: store the selected verifier in session and redirect to eligibility:start
@thekaveman thekaveman added this to the Courtesy Cards milestone Mar 16, 2022
@thekaveman thekaveman moved this to This Sprint in Digital Services Mar 16, 2022
@thekaveman thekaveman moved this from This Sprint to Blocked in Digital Services Mar 16, 2022
@thekaveman thekaveman moved this from Blocked to This Sprint in Digital Services Mar 17, 2022
@thekaveman thekaveman self-assigned this Mar 18, 2022
@thekaveman thekaveman moved this from This Sprint to Blocked in Digital Services Mar 18, 2022
@thekaveman thekaveman removed their assignment Mar 18, 2022
@angela-tran angela-tran moved this from Blocked to In Progress in Digital Services Mar 22, 2022
@angela-tran angela-tran self-assigned this Mar 22, 2022
@thekaveman
Copy link
Member Author

FYI @angela-tran I moved a few of these items (creating the new sample data) to #338, so this one is now strictly to implement the form logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants