Coverage for benefits/in_person/forms.py: 100%
21 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 18:00 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 18:00 +0000
1"""
2The in-person eligibility application: Form definition for the
3in-person eligibility verification flow, in which a
4transit agency employee manually verifies a rider's eligibility.
5"""
7from django import forms
8from benefits.routes import routes
9from benefits.core import models
10from benefits.enrollment.forms import CardTokenizeFailForm, CardTokenizeSuccessForm # noqa
13class InPersonEligibilityForm(forms.Form):
14 """Form to capture eligibility for in-person verification flow selection."""
16 action_url = routes.IN_PERSON_ELIGIBILITY
17 id = "form-flow-selection"
18 method = "POST"
20 flow = forms.ChoiceField(label="Choose an eligibility type to qualify this rider.", widget=forms.widgets.RadioSelect)
21 verified = forms.BooleanField(label="I have verified this person’s eligibility for a transit benefit.", required=True)
23 cancel_url = routes.ADMIN_INDEX
25 def __init__(self, agency: models.TransitAgency, *args, **kwargs):
26 super().__init__(*args, **kwargs)
27 flows = agency.enrollment_flows.filter(supported_enrollment_methods__contains=models.EnrollmentMethods.IN_PERSON)
29 self.classes = "checkbox-parent"
30 flow_field = self.fields["flow"]
31 verified_field = self.fields["verified"]
33 flow_field.choices = [(f.id, f.label) for f in flows]
34 flow_field.widget.attrs.update({"data-custom-validity": "Please choose an eligibility type."})
35 verified_field.widget.attrs.update(
36 {"data-custom-validity": "Please confirm you have used an agency policy to verify eligibility."}
37 )
38 self.use_custom_validity = True