We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Refactor language files for multiple verifiers
## Background

We need message strings for multiple verifiers

## Tasks

* [x] Create a new [verifier fixture](https://github.com/cal-itp/benefits/blob/dev/fixtures/02_eligibilityverifier.json) from the existing one
  * [x] With a new `pk` and `fields.name`
  * [x] Adjust both to have different `msgid`, e.g. `eligibility.pages.confirm.dmv.*` and `eligibility.pages.confirm.mst.*`
* [x] Adjust the `django.po` files with new `msgid` and new sample content for the Courtesy Cards verifier for each language
* [x] Wire the above fixture to one of the [sample agencies](https://github.com/cal-itp/benefits/blob/dev/fixtures/04_transitagency.json)

## Testing

Once #322 is merged

* [x] Remove your local db and local compiled language files, then run `bin/init.sh`
  * [x] Observe that the migrations run correctly, the fixture data is loaded, and the language files are compiled
* [x] Open the app locally and select the agency configured above with multiple verifiers
  * [x] Observe the `eligibility:index` view with different verifier selections
* [x] Select one of the verifiers
  * [x] Observe the verifier-specific `eligibility:start` view
  * [x] Confirm verification of a test user
* [x] Go back to `eligibility:index` and select the other verifier
  * [x] Observe the verifier-specific `eligibility:start` view
  * [x] Confirm verification of a test user

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `benefits/eligibility/views.py`
Content:
```
1 """
2 The eligibility application: view definitions for the eligibility verification flow.
3 """
4 from django.contrib import messages
5 from django.shortcuts import redirect
6 from django.urls import reverse
7 from django.utils.decorators import decorator_from_middleware
8 from django.utils.translation import pgettext, gettext as _
9 
10 from benefits.core import middleware, recaptcha, session, viewmodels
11 from benefits.core.models import EligibilityVerifier
12 from benefits.core.views import PageTemplateResponse, _index_image
13 from . import analytics, api, forms
14 
15 
16 @decorator_from_middleware(middleware.AgencySessionRequired)
17 def index(request):
18     """View handler for the eligibility verifier selection form."""
19 
20     session.update(request, eligibility_types=[], origin=reverse("eligibility:index"))
21     agency = session.agency(request)
22 
23     eligibility_start = reverse("eligibility:start")
24 
25     page = viewmodels.Page(
26         title=_("eligibility.pages.index.title"),
27         content_title=_("eligibility.pages.index.content_title"),
28         forms=forms.EligibilityVerifierSelectionForm(agency=agency),
29         image=_index_image(),
30     )
31 
32     if request.method == "POST":
33         form = forms.EligibilityVerifierSelectionForm(data=request.POST, agency=agency)
34 
35         if form.is_valid():
36             verifier_id = form.cleaned_data.get("verifier")
37             verifier = EligibilityVerifier.objects.get(id=verifier_id)
38             session.update(request, verifier=verifier)
39 
40             response = redirect(eligibility_start)
41         else:
42             # form was not valid, allow for correction/resubmission
43             page.forms = [form]
44             response = PageTemplateResponse(request, page)
45     else:
46         if agency.eligibility_verifiers.count() == 1:
47             verifier = agency.eligibility_verifiers.first()
48             session.update(request, verifier=verifier)
49             response = redirect(eligibility_start)
50         else:
51             response = PageTemplateResponse(request, page)
52 
53     return response
54 
55 
56 @decorator_from_middleware(middleware.AgencySessionRequired)
57 @decorator_from_middleware(middleware.VerifierSessionRequired)
58 def start(request):
59     """View handler for the eligibility verification getting started screen."""
60 
61     verifier = session.verifier(request)
62 
63     page = viewmodels.Page(
64         title=_("eligibility.pages.start.title"),
65         content_title=_(verifier.start_content_title),
66         media=[
67             viewmodels.MediaItem(
68                 icon=viewmodels.Icon("idcardcheck", pgettext("image alt text", "core.icons.idcardcheck")),
69                 heading=_(verifier.start_item_name),
70                 details=_(verifier.start_item_description),
71             ),
72             viewmodels.MediaItem(
73                 icon=viewmodels.Icon("bankcardcheck", pgettext("image alt text", "core.icons.bankcardcheck")),
74                 heading=_("eligibility.pages.start.items[1].title"),
75                 details=_("eligibility.pages.start.items[1].text"),
76             ),
77         ],
78         paragraphs=[_(verifier.start_blurb)],
79         image=_index_image(),
80         button=viewmodels.Button.primary(text=_("eligibility.pages.start.button"), url=reverse("eligibility:confirm")),
81     )
82 
83     return PageTemplateResponse(request, page)
84 
85 
86 @decorator_from_middleware(middleware.AgencySessionRequired)
87 @decorator_from_middleware(middleware.RateLimit)
88 @decorator_from_middleware(middleware.VerifierSessionRequired)
89 def confirm(request):
90     """View handler for the eligibility verification form."""
91 
92     verifier = session.verifier(request)
93 
94     page = viewmodels.Page(
95         title=_(verifier.form_title),
96         content_title=_(verifier.form_content_title),
97         paragraphs=[_(verifier.form_blurb)],
98         form=forms.EligibilityVerificationForm(auto_id=True, label_suffix="", verifier=verifier),
99         classes="text-lg-center",
100     )
101 
102     if request.method == "POST":
103         analytics.started_eligibility(request)
104 
105         form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)
106         response = _verify(request, form)
107 
108         if response is None:
109             # form was not valid, allow for correction/resubmission
110             analytics.returned_error(request, form.errors)
111             page.forms = [form]
112             response = PageTemplateResponse(request, page)
113     elif session.eligible(request):
114         eligibility = session.eligibility(request)
115         response = verified(request, [eligibility.name])
116     else:
117         response = PageTemplateResponse(request, page)
118 
119     return response
120 
121 
122 def _verify(request, form):
123     """Helper calls the eligibility verification API with user input."""
124 
125     if not form.is_valid():
126         if recaptcha.has_error(form):
127             messages.error(request, "Recaptcha failed. Please try again.")
128         return None
129 
130     sub, name = form.cleaned_data.get("sub"), form.cleaned_data.get("name")
131 
132     agency = session.agency(request)
133     verifier = session.verifier(request)
134     client = api.Client(agency, verifier)
135 
136     response = client.verify(sub, name)
137 
138     if response.error and any(response.error):
139         form.add_api_errors(response.error)
140         return None
141     elif any(response.eligibility):
142         return verified(request, response.eligibility)
143     else:
144         return unverified(request)
145 
146 
147 @decorator_from_middleware(middleware.AgencySessionRequired)
148 def verified(request, verified_types):
149     """View handler for the verified eligibility page."""
150 
151     analytics.returned_success(request)
152 
153     enrollment_index = reverse("enrollment:index")
154     session.update(request, eligibility_types=verified_types, origin=enrollment_index)
155 
156     return redirect(enrollment_index)
157 
158 
159 @decorator_from_middleware(middleware.AgencySessionRequired)
160 def unverified(request):
161     """View handler for the unverified eligibility page."""
162 
163     analytics.returned_fail(request)
164 
165     # tel: link to agency phone number
166     agency = session.agency(request)
167     buttons = viewmodels.Button.agency_contact_links(agency)
168 
169     page = viewmodels.Page(
170         title=_("eligibility.pages.unverified.title"),
171         content_title=_("eligibility.pages.unverified.content_title"),
172         icon=viewmodels.Icon("idcardquestion", pgettext("image alt text", "core.icons.idcardquestion")),
173         paragraphs=[_("eligibility.pages.unverified.p[0]"), _("eligibility.pages.unverified.p[1]")],
174         buttons=buttons,
175         classes="text-lg-center",
176     )
177 
178     return PageTemplateResponse(request, page)
179
```

Path: `benefits/eligibility/forms.py`
Content:
```
1 """
2 The eligibility application: Form definition for the eligibility verification flow.
3 """
4 import logging
5 
6 from django import forms
7 from django.utils.translation import gettext_lazy as _
8 
9 from benefits.core import models, recaptcha, widgets
10 
11 
12 logger = logging.getLogger(__name__)
13 
14 
15 class EligibilityVerifierSelectionForm(forms.Form):
16     """Form to capture eligibility verifier selection."""
17 
18     action_url = "eligibility:index"
19     method = "POST"
20 
21     verifier = forms.ChoiceField(label="", widget=forms.RadioSelect)
22 
23     submit_value = _("eligibility.pages.index.button")
24 
25     def __init__(self, agency: models.TransitAgency, *args, **kwargs):
26         super().__init__(*args, **kwargs)
27         choices = [(v.id, v.selection_label) for v in agency.eligibility_verifiers.all()]
28         self.fields["verifier"].choices = choices
29 
30 
31 class EligibilityVerificationForm(forms.Form):
32     """Form to collect eligibility verification details."""
33 
34     action_url = "eligibility:confirm"
35     method = "POST"
36 
37     submit_value = _("eligibility.forms.confirm.submit")
38     submitting_value = _("eligibility.forms.confirm.submitting")
39 
40     _error_messages = {
41         "invalid": _("eligibility.forms.confirm.errors.invalid"),
42         "missing": _("eligibility.forms.confirm.errors.missing"),
43     }
44 
45     def __init__(self, verifier: models.EligibilityVerifier, *args, **kwargs):
46         super().__init__(*args, **kwargs)
47 
48         sub_widget = widgets.FormControlTextInput(placeholder=verifier.form_sub_placeholder)
49         if verifier.form_sub_pattern:
50             sub_widget.attrs.update({"pattern": verifier.form_sub_pattern})
51 
52         self.fields["sub"] = forms.CharField(label=_(verifier.form_sub_label), widget=sub_widget)
53 
54         name_widget = widgets.FormControlTextInput(placeholder=verifier.form_name_placeholder)
55         if verifier.form_name_max_length:
56             name_widget.attrs.update({"maxlength": verifier.form_name_max_length})
57 
58         self.fields["name"] = forms.CharField(label=_(verifier.form_name_label), widget=name_widget)
59 
60     def add_api_errors(self, form_errors):
61         """Handle errors passed back from API server related to submitted form values."""
62 
63         validation_errors = {
64             field: forms.ValidationError(self._error_messages.get(code, _("core.pages.error.title")), code=code)
65             for (field, code) in form_errors.items()
66             if field in self.fields
67         }
68 
69         if len(validation_errors) > 0:
70             logger.warning("Form fields are invalid")
71 
72         for (field, err) in validation_errors.items():
73             self.add_error(field, err)
74 
75     def clean(self):
76         if not recaptcha.verify(self.data):
77             raise forms.ValidationError("reCAPTCHA failed")
78
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py
--- a/benefits/eligibility/forms.py
+++ b/benefits/eligibility/forms.py
@@ -20,11 +20,11 @@
 
     verifier = forms.ChoiceField(label="", widget=forms.RadioSelect)
 
-    submit_value = _("eligibility.pages.index.button")
+    submit_value = _("eligibility.buttons.continue")
 
     def __init__(self, agency: models.TransitAgency, *args, **kwargs):
         super().__init__(*args, **kwargs)
-        choices = [(v.id, v.selection_label) for v in agency.eligibility_verifiers.all()]
+        choices = [(v.id, _(v.selection_label)) for v in agency.eligibility_verifiers.all()]
         self.fields["verifier"].choices = choices
 
 
diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py
--- a/benefits/eligibility/views.py
+++ b/benefits/eligibility/views.py
@@ -77,7 +77,7 @@
         ],
         paragraphs=[_(verifier.start_blurb)],
         image=_index_image(),
-        button=viewmodels.Button.primary(text=_("eligibility.pages.start.button"), url=reverse("eligibility:confirm")),
+        button=viewmodels.Button.primary(text=_("eligibility.buttons.continue"), url=reverse("eligibility:confirm")),
     )
 
     return PageTemplateResponse(request, page)

{"golden_diff": "diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py\n--- a/benefits/eligibility/forms.py\n+++ b/benefits/eligibility/forms.py\n@@ -20,11 +20,11 @@\n \n     verifier = forms.ChoiceField(label=\"\", widget=forms.RadioSelect)\n \n-    submit_value = _(\"eligibility.pages.index.button\")\n+    submit_value = _(\"eligibility.buttons.continue\")\n \n     def __init__(self, agency: models.TransitAgency, *args, **kwargs):\n         super().__init__(*args, **kwargs)\n-        choices = [(v.id, v.selection_label) for v in agency.eligibility_verifiers.all()]\n+        choices = [(v.id, _(v.selection_label)) for v in agency.eligibility_verifiers.all()]\n         self.fields[\"verifier\"].choices = choices\n \n \ndiff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py\n--- a/benefits/eligibility/views.py\n+++ b/benefits/eligibility/views.py\n@@ -77,7 +77,7 @@\n         ],\n         paragraphs=[_(verifier.start_blurb)],\n         image=_index_image(),\n-        button=viewmodels.Button.primary(text=_(\"eligibility.pages.start.button\"), url=reverse(\"eligibility:confirm\")),\n+        button=viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(\"eligibility:confirm\")),\n     )\n \n     return PageTemplateResponse(request, page)\n", "issue": "Refactor language files for multiple verifiers\n## Background\r\n\r\nWe need message strings for multiple verifiers\r\n\r\n## Tasks\r\n\r\n* [x] Create a new [verifier fixture](https://github.com/cal-itp/benefits/blob/dev/fixtures/02_eligibilityverifier.json) from the existing one\r\n  * [x] With a new `pk` and `fields.name`\r\n  * [x] Adjust both to have different `msgid`, e.g. `eligibility.pages.confirm.dmv.*` and `eligibility.pages.confirm.mst.*`\r\n* [x] Adjust the `django.po` files with new `msgid` and new sample content for the Courtesy Cards verifier for each language\r\n* [x] Wire the above fixture to one of the [sample agencies](https://github.com/cal-itp/benefits/blob/dev/fixtures/04_transitagency.json)\r\n\r\n## Testing\r\n\r\nOnce #322 is merged\r\n\r\n* [x] Remove your local db and local compiled language files, then run `bin/init.sh`\r\n  * [x] Observe that the migrations run correctly, the fixture data is loaded, and the language files are compiled\r\n* [x] Open the app locally and select the agency configured above with multiple verifiers\r\n  * [x] Observe the `eligibility:index` view with different verifier selections\r\n* [x] Select one of the verifiers\r\n  * [x] Observe the verifier-specific `eligibility:start` view\r\n  * [x] Confirm verification of a test user\r\n* [x] Go back to `eligibility:index` and select the other verifier\r\n  * [x] Observe the verifier-specific `eligibility:start` view\r\n  * [x] Confirm verification of a test user\n", "before_files": [{"content": "\"\"\"\nThe eligibility application: view definitions for the eligibility verification flow.\n\"\"\"\nfrom django.contrib import messages\nfrom django.shortcuts import redirect\nfrom django.urls import reverse\nfrom django.utils.decorators import decorator_from_middleware\nfrom django.utils.translation import pgettext, gettext as _\n\nfrom benefits.core import middleware, recaptcha, session, viewmodels\nfrom benefits.core.models import EligibilityVerifier\nfrom benefits.core.views import PageTemplateResponse, _index_image\nfrom . import analytics, api, forms\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\ndef index(request):\n    \"\"\"View handler for the eligibility verifier selection form.\"\"\"\n\n    session.update(request, eligibility_types=[], origin=reverse(\"eligibility:index\"))\n    agency = session.agency(request)\n\n    eligibility_start = reverse(\"eligibility:start\")\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.index.title\"),\n        content_title=_(\"eligibility.pages.index.content_title\"),\n        forms=forms.EligibilityVerifierSelectionForm(agency=agency),\n        image=_index_image(),\n    )\n\n    if request.method == \"POST\":\n        form = forms.EligibilityVerifierSelectionForm(data=request.POST, agency=agency)\n\n        if form.is_valid():\n            verifier_id = form.cleaned_data.get(\"verifier\")\n            verifier = EligibilityVerifier.objects.get(id=verifier_id)\n            session.update(request, verifier=verifier)\n\n            response = redirect(eligibility_start)\n        else:\n            # form was not valid, allow for correction/resubmission\n            page.forms = [form]\n            response = PageTemplateResponse(request, page)\n    else:\n        if agency.eligibility_verifiers.count() == 1:\n            verifier = agency.eligibility_verifiers.first()\n            session.update(request, verifier=verifier)\n            response = redirect(eligibility_start)\n        else:\n            response = PageTemplateResponse(request, page)\n\n    return response\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\n@decorator_from_middleware(middleware.VerifierSessionRequired)\ndef start(request):\n    \"\"\"View handler for the eligibility verification getting started screen.\"\"\"\n\n    verifier = session.verifier(request)\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.start.title\"),\n        content_title=_(verifier.start_content_title),\n        media=[\n            viewmodels.MediaItem(\n                icon=viewmodels.Icon(\"idcardcheck\", pgettext(\"image alt text\", \"core.icons.idcardcheck\")),\n                heading=_(verifier.start_item_name),\n                details=_(verifier.start_item_description),\n            ),\n            viewmodels.MediaItem(\n                icon=viewmodels.Icon(\"bankcardcheck\", pgettext(\"image alt text\", \"core.icons.bankcardcheck\")),\n                heading=_(\"eligibility.pages.start.items[1].title\"),\n                details=_(\"eligibility.pages.start.items[1].text\"),\n            ),\n        ],\n        paragraphs=[_(verifier.start_blurb)],\n        image=_index_image(),\n        button=viewmodels.Button.primary(text=_(\"eligibility.pages.start.button\"), url=reverse(\"eligibility:confirm\")),\n    )\n\n    return PageTemplateResponse(request, page)\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\n@decorator_from_middleware(middleware.RateLimit)\n@decorator_from_middleware(middleware.VerifierSessionRequired)\ndef confirm(request):\n    \"\"\"View handler for the eligibility verification form.\"\"\"\n\n    verifier = session.verifier(request)\n\n    page = viewmodels.Page(\n        title=_(verifier.form_title),\n        content_title=_(verifier.form_content_title),\n        paragraphs=[_(verifier.form_blurb)],\n        form=forms.EligibilityVerificationForm(auto_id=True, label_suffix=\"\", verifier=verifier),\n        classes=\"text-lg-center\",\n    )\n\n    if request.method == \"POST\":\n        analytics.started_eligibility(request)\n\n        form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)\n        response = _verify(request, form)\n\n        if response is None:\n            # form was not valid, allow for correction/resubmission\n            analytics.returned_error(request, form.errors)\n            page.forms = [form]\n            response = PageTemplateResponse(request, page)\n    elif session.eligible(request):\n        eligibility = session.eligibility(request)\n        response = verified(request, [eligibility.name])\n    else:\n        response = PageTemplateResponse(request, page)\n\n    return response\n\n\ndef _verify(request, form):\n    \"\"\"Helper calls the eligibility verification API with user input.\"\"\"\n\n    if not form.is_valid():\n        if recaptcha.has_error(form):\n            messages.error(request, \"Recaptcha failed. Please try again.\")\n        return None\n\n    sub, name = form.cleaned_data.get(\"sub\"), form.cleaned_data.get(\"name\")\n\n    agency = session.agency(request)\n    verifier = session.verifier(request)\n    client = api.Client(agency, verifier)\n\n    response = client.verify(sub, name)\n\n    if response.error and any(response.error):\n        form.add_api_errors(response.error)\n        return None\n    elif any(response.eligibility):\n        return verified(request, response.eligibility)\n    else:\n        return unverified(request)\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\ndef verified(request, verified_types):\n    \"\"\"View handler for the verified eligibility page.\"\"\"\n\n    analytics.returned_success(request)\n\n    enrollment_index = reverse(\"enrollment:index\")\n    session.update(request, eligibility_types=verified_types, origin=enrollment_index)\n\n    return redirect(enrollment_index)\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\ndef unverified(request):\n    \"\"\"View handler for the unverified eligibility page.\"\"\"\n\n    analytics.returned_fail(request)\n\n    # tel: link to agency phone number\n    agency = session.agency(request)\n    buttons = viewmodels.Button.agency_contact_links(agency)\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.unverified.title\"),\n        content_title=_(\"eligibility.pages.unverified.content_title\"),\n        icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n        paragraphs=[_(\"eligibility.pages.unverified.p[0]\"), _(\"eligibility.pages.unverified.p[1]\")],\n        buttons=buttons,\n        classes=\"text-lg-center\",\n    )\n\n    return PageTemplateResponse(request, page)\n", "path": "benefits/eligibility/views.py"}, {"content": "\"\"\"\nThe eligibility application: Form definition for the eligibility verification flow.\n\"\"\"\nimport logging\n\nfrom django import forms\nfrom django.utils.translation import gettext_lazy as _\n\nfrom benefits.core import models, recaptcha, widgets\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass EligibilityVerifierSelectionForm(forms.Form):\n    \"\"\"Form to capture eligibility verifier selection.\"\"\"\n\n    action_url = \"eligibility:index\"\n    method = \"POST\"\n\n    verifier = forms.ChoiceField(label=\"\", widget=forms.RadioSelect)\n\n    submit_value = _(\"eligibility.pages.index.button\")\n\n    def __init__(self, agency: models.TransitAgency, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        choices = [(v.id, v.selection_label) for v in agency.eligibility_verifiers.all()]\n        self.fields[\"verifier\"].choices = choices\n\n\nclass EligibilityVerificationForm(forms.Form):\n    \"\"\"Form to collect eligibility verification details.\"\"\"\n\n    action_url = \"eligibility:confirm\"\n    method = \"POST\"\n\n    submit_value = _(\"eligibility.forms.confirm.submit\")\n    submitting_value = _(\"eligibility.forms.confirm.submitting\")\n\n    _error_messages = {\n        \"invalid\": _(\"eligibility.forms.confirm.errors.invalid\"),\n        \"missing\": _(\"eligibility.forms.confirm.errors.missing\"),\n    }\n\n    def __init__(self, verifier: models.EligibilityVerifier, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        sub_widget = widgets.FormControlTextInput(placeholder=verifier.form_sub_placeholder)\n        if verifier.form_sub_pattern:\n            sub_widget.attrs.update({\"pattern\": verifier.form_sub_pattern})\n\n        self.fields[\"sub\"] = forms.CharField(label=_(verifier.form_sub_label), widget=sub_widget)\n\n        name_widget = widgets.FormControlTextInput(placeholder=verifier.form_name_placeholder)\n        if verifier.form_name_max_length:\n            name_widget.attrs.update({\"maxlength\": verifier.form_name_max_length})\n\n        self.fields[\"name\"] = forms.CharField(label=_(verifier.form_name_label), widget=name_widget)\n\n    def add_api_errors(self, form_errors):\n        \"\"\"Handle errors passed back from API server related to submitted form values.\"\"\"\n\n        validation_errors = {\n            field: forms.ValidationError(self._error_messages.get(code, _(\"core.pages.error.title\")), code=code)\n            for (field, code) in form_errors.items()\n            if field in self.fields\n        }\n\n        if len(validation_errors) > 0:\n            logger.warning(\"Form fields are invalid\")\n\n        for (field, err) in validation_errors.items():\n            self.add_error(field, err)\n\n    def clean(self):\n        if not recaptcha.verify(self.data):\n            raise forms.ValidationError(\"reCAPTCHA failed\")\n", "path": "benefits/eligibility/forms.py"}], "after_files": [{"content": "\"\"\"\nThe eligibility application: view definitions for the eligibility verification flow.\n\"\"\"\nfrom django.contrib import messages\nfrom django.shortcuts import redirect\nfrom django.urls import reverse\nfrom django.utils.decorators import decorator_from_middleware\nfrom django.utils.translation import pgettext, gettext as _\n\nfrom benefits.core import middleware, recaptcha, session, viewmodels\nfrom benefits.core.models import EligibilityVerifier\nfrom benefits.core.views import PageTemplateResponse, _index_image\nfrom . import analytics, api, forms\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\ndef index(request):\n    \"\"\"View handler for the eligibility verifier selection form.\"\"\"\n\n    session.update(request, eligibility_types=[], origin=reverse(\"eligibility:index\"))\n    agency = session.agency(request)\n\n    eligibility_start = reverse(\"eligibility:start\")\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.index.title\"),\n        content_title=_(\"eligibility.pages.index.content_title\"),\n        forms=forms.EligibilityVerifierSelectionForm(agency=agency),\n        image=_index_image(),\n    )\n\n    if request.method == \"POST\":\n        form = forms.EligibilityVerifierSelectionForm(data=request.POST, agency=agency)\n\n        if form.is_valid():\n            verifier_id = form.cleaned_data.get(\"verifier\")\n            verifier = EligibilityVerifier.objects.get(id=verifier_id)\n            session.update(request, verifier=verifier)\n\n            response = redirect(eligibility_start)\n        else:\n            # form was not valid, allow for correction/resubmission\n            page.forms = [form]\n            response = PageTemplateResponse(request, page)\n    else:\n        if agency.eligibility_verifiers.count() == 1:\n            verifier = agency.eligibility_verifiers.first()\n            session.update(request, verifier=verifier)\n            response = redirect(eligibility_start)\n        else:\n            response = PageTemplateResponse(request, page)\n\n    return response\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\n@decorator_from_middleware(middleware.VerifierSessionRequired)\ndef start(request):\n    \"\"\"View handler for the eligibility verification getting started screen.\"\"\"\n\n    verifier = session.verifier(request)\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.start.title\"),\n        content_title=_(verifier.start_content_title),\n        media=[\n            viewmodels.MediaItem(\n                icon=viewmodels.Icon(\"idcardcheck\", pgettext(\"image alt text\", \"core.icons.idcardcheck\")),\n                heading=_(verifier.start_item_name),\n                details=_(verifier.start_item_description),\n            ),\n            viewmodels.MediaItem(\n                icon=viewmodels.Icon(\"bankcardcheck\", pgettext(\"image alt text\", \"core.icons.bankcardcheck\")),\n                heading=_(\"eligibility.pages.start.items[1].title\"),\n                details=_(\"eligibility.pages.start.items[1].text\"),\n            ),\n        ],\n        paragraphs=[_(verifier.start_blurb)],\n        image=_index_image(),\n        button=viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(\"eligibility:confirm\")),\n    )\n\n    return PageTemplateResponse(request, page)\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\n@decorator_from_middleware(middleware.RateLimit)\n@decorator_from_middleware(middleware.VerifierSessionRequired)\ndef confirm(request):\n    \"\"\"View handler for the eligibility verification form.\"\"\"\n\n    verifier = session.verifier(request)\n\n    page = viewmodels.Page(\n        title=_(verifier.form_title),\n        content_title=_(verifier.form_content_title),\n        paragraphs=[_(verifier.form_blurb)],\n        form=forms.EligibilityVerificationForm(auto_id=True, label_suffix=\"\", verifier=verifier),\n        classes=\"text-lg-center\",\n    )\n\n    if request.method == \"POST\":\n        analytics.started_eligibility(request)\n\n        form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)\n        response = _verify(request, form)\n\n        if response is None:\n            # form was not valid, allow for correction/resubmission\n            analytics.returned_error(request, form.errors)\n            page.forms = [form]\n            response = PageTemplateResponse(request, page)\n    elif session.eligible(request):\n        eligibility = session.eligibility(request)\n        response = verified(request, [eligibility.name])\n    else:\n        response = PageTemplateResponse(request, page)\n\n    return response\n\n\ndef _verify(request, form):\n    \"\"\"Helper calls the eligibility verification API with user input.\"\"\"\n\n    if not form.is_valid():\n        if recaptcha.has_error(form):\n            messages.error(request, \"Recaptcha failed. Please try again.\")\n        return None\n\n    sub, name = form.cleaned_data.get(\"sub\"), form.cleaned_data.get(\"name\")\n\n    agency = session.agency(request)\n    verifier = session.verifier(request)\n    client = api.Client(agency, verifier)\n\n    response = client.verify(sub, name)\n\n    if response.error and any(response.error):\n        form.add_api_errors(response.error)\n        return None\n    elif any(response.eligibility):\n        return verified(request, response.eligibility)\n    else:\n        return unverified(request)\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\ndef verified(request, verified_types):\n    \"\"\"View handler for the verified eligibility page.\"\"\"\n\n    analytics.returned_success(request)\n\n    enrollment_index = reverse(\"enrollment:index\")\n    session.update(request, eligibility_types=verified_types, origin=enrollment_index)\n\n    return redirect(enrollment_index)\n\n\n@decorator_from_middleware(middleware.AgencySessionRequired)\ndef unverified(request):\n    \"\"\"View handler for the unverified eligibility page.\"\"\"\n\n    analytics.returned_fail(request)\n\n    # tel: link to agency phone number\n    agency = session.agency(request)\n    buttons = viewmodels.Button.agency_contact_links(agency)\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.unverified.title\"),\n        content_title=_(\"eligibility.pages.unverified.content_title\"),\n        icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n        paragraphs=[_(\"eligibility.pages.unverified.p[0]\"), _(\"eligibility.pages.unverified.p[1]\")],\n        buttons=buttons,\n        classes=\"text-lg-center\",\n    )\n\n    return PageTemplateResponse(request, page)\n", "path": "benefits/eligibility/views.py"}, {"content": "\"\"\"\nThe eligibility application: Form definition for the eligibility verification flow.\n\"\"\"\nimport logging\n\nfrom django import forms\nfrom django.utils.translation import gettext_lazy as _\n\nfrom benefits.core import models, recaptcha, widgets\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass EligibilityVerifierSelectionForm(forms.Form):\n    \"\"\"Form to capture eligibility verifier selection.\"\"\"\n\n    action_url = \"eligibility:index\"\n    method = \"POST\"\n\n    verifier = forms.ChoiceField(label=\"\", widget=forms.RadioSelect)\n\n    submit_value = _(\"eligibility.buttons.continue\")\n\n    def __init__(self, agency: models.TransitAgency, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        choices = [(v.id, _(v.selection_label)) for v in agency.eligibility_verifiers.all()]\n        self.fields[\"verifier\"].choices = choices\n\n\nclass EligibilityVerificationForm(forms.Form):\n    \"\"\"Form to collect eligibility verification details.\"\"\"\n\n    action_url = \"eligibility:confirm\"\n    method = \"POST\"\n\n    submit_value = _(\"eligibility.forms.confirm.submit\")\n    submitting_value = _(\"eligibility.forms.confirm.submitting\")\n\n    _error_messages = {\n        \"invalid\": _(\"eligibility.forms.confirm.errors.invalid\"),\n        \"missing\": _(\"eligibility.forms.confirm.errors.missing\"),\n    }\n\n    def __init__(self, verifier: models.EligibilityVerifier, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        sub_widget = widgets.FormControlTextInput(placeholder=verifier.form_sub_placeholder)\n        if verifier.form_sub_pattern:\n            sub_widget.attrs.update({\"pattern\": verifier.form_sub_pattern})\n\n        self.fields[\"sub\"] = forms.CharField(label=_(verifier.form_sub_label), widget=sub_widget)\n\n        name_widget = widgets.FormControlTextInput(placeholder=verifier.form_name_placeholder)\n        if verifier.form_name_max_length:\n            name_widget.attrs.update({\"maxlength\": verifier.form_name_max_length})\n\n        self.fields[\"name\"] = forms.CharField(label=_(verifier.form_name_label), widget=name_widget)\n\n    def add_api_errors(self, form_errors):\n        \"\"\"Handle errors passed back from API server related to submitted form values.\"\"\"\n\n        validation_errors = {\n            field: forms.ValidationError(self._error_messages.get(code, _(\"core.pages.error.title\")), code=code)\n            for (field, code) in form_errors.items()\n            if field in self.fields\n        }\n\n        if len(validation_errors) > 0:\n            logger.warning(\"Form fields are invalid\")\n\n        for (field, err) in validation_errors.items():\n            self.add_error(field, err)\n\n    def clean(self):\n        if not recaptcha.verify(self.data):\n            raise forms.ValidationError(\"reCAPTCHA failed\")\n", "path": "benefits/eligibility/forms.py"}]}