We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
"Learn more about Login.gov" link should go to `/help#login-gov`
### Steps to reproduce
On the `eligibility:start` page, click the "Learn more about Login.gov" link.

### Expected result
The link goes to the "What is Login.gov?" section on the Help page.

### Actual result
The link goes to `https://login.gov`.


--- 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.conf import settings
5 from django.contrib import messages
6 from django.shortcuts import redirect
7 from django.template.response import TemplateResponse
8 from django.urls import reverse
9 from django.utils.decorators import decorator_from_middleware
10 from django.utils.translation import pgettext, gettext as _
11 
12 from benefits.core import recaptcha, session, viewmodels
13 from benefits.core.middleware import AgencySessionRequired, LoginRequired, RateLimit, VerifierSessionRequired
14 from benefits.core.models import EligibilityVerifier
15 from benefits.core.views import PageTemplateResponse
16 from . import analytics, api, forms
17 
18 
19 @decorator_from_middleware(AgencySessionRequired)
20 def index(request):
21     """View handler for the eligibility verifier selection form."""
22 
23     session.update(request, eligibility_types=[], origin=reverse("eligibility:index"))
24     agency = session.agency(request)
25 
26     eligibility_start = reverse("eligibility:start")
27 
28     page = viewmodels.Page(
29         title=_("eligibility.pages.index.title"),
30         content_title=_("eligibility.pages.index.content_title"),
31         forms=forms.EligibilityVerifierSelectionForm(agency=agency),
32     )
33 
34     if request.method == "POST":
35         form = forms.EligibilityVerifierSelectionForm(data=request.POST, agency=agency)
36 
37         if form.is_valid():
38             verifier_id = form.cleaned_data.get("verifier")
39             verifier = EligibilityVerifier.objects.get(id=verifier_id)
40             session.update(request, verifier=verifier)
41 
42             response = redirect(eligibility_start)
43         else:
44             # form was not valid, allow for correction/resubmission
45             page.forms = [form]
46             response = PageTemplateResponse(request, page)
47     else:
48         if agency.eligibility_verifiers.count() == 1:
49             verifier = agency.eligibility_verifiers.first()
50             session.update(request, verifier=verifier)
51             response = redirect(eligibility_start)
52         else:
53             response = PageTemplateResponse(request, page)
54 
55     return response
56 
57 
58 @decorator_from_middleware(AgencySessionRequired)
59 @decorator_from_middleware(VerifierSessionRequired)
60 def start(request):
61     """View handler for the eligibility verification getting started screen."""
62 
63     session.update(request, eligibility_types=[], origin=reverse("eligibility:start"))
64     verifier = session.verifier(request)
65 
66     button = viewmodels.Button.primary(text=_("eligibility.buttons.continue"), url=reverse("eligibility:confirm"))
67     media = [
68         dict(
69             icon=viewmodels.Icon("idcardcheck", pgettext("image alt text", "core.icons.idcardcheck")),
70             heading=_(verifier.start_item_name),
71             details=_(verifier.start_item_description),
72         ),
73         dict(
74             icon=viewmodels.Icon("bankcardcheck", pgettext("image alt text", "core.icons.bankcardcheck")),
75             heading=_("eligibility.pages.start.items[1].title"),
76             details=_("eligibility.pages.start.items[1].text"),
77             links=[
78                 viewmodels.Button.link(
79                     classes="btn-text btn-link",
80                     text=_("eligibility.pages.start.items[1].button[0].link"),
81                     url=_("eligibility.pages.start.items[1].button[0].url"),
82                 ),
83                 viewmodels.Button.link(
84                     classes="btn-text btn-link",
85                     text=_("eligibility.pages.start.items[1].button[1].link"),
86                     url=_("eligibility.pages.start.items[1].button[1].url"),
87                 ),
88             ],
89         ),
90     ]
91 
92     if verifier.requires_authentication:
93         if settings.OAUTH_CLIENT_NAME is None:
94             raise Exception("EligibilityVerifier requires authentication, but OAUTH_CLIENT_NAME is None")
95 
96         media.insert(
97             0,
98             dict(
99                 icon=viewmodels.Icon("idscreencheck", pgettext("image alt text", "core.icons.idscreencheck")),
100                 heading=_("eligibility.media.heading"),
101                 details=_("eligibility.media.details"),
102                 links=[
103                     viewmodels.Button.link(
104                         classes="btn-text btn-link",
105                         text=_("eligibility.media.link_text"),
106                         url=_("eligibility.media.link_url"),
107                         target="_blank",
108                         rel="noopener noreferrer",
109                     )
110                 ],
111             ),
112         )
113 
114         if not session.logged_in(request):
115             button = viewmodels.Button.login(
116                 label=_(verifier.auth_provider.sign_in_button_label),
117                 text="",
118                 url=reverse("oauth:login"),
119             )
120 
121     page = viewmodels.Page(
122         title=_("eligibility.pages.start.title"),
123         noimage=True,
124         paragraphs=[_(verifier.start_blurb)],
125         button=button,
126     )
127 
128     ctx = page.context_dict()
129     ctx["title"] = _(verifier.start_content_title)
130     ctx["media"] = media
131 
132     return TemplateResponse(request, "eligibility/start.html", ctx)
133 
134 
135 @decorator_from_middleware(AgencySessionRequired)
136 @decorator_from_middleware(LoginRequired)
137 @decorator_from_middleware(RateLimit)
138 @decorator_from_middleware(VerifierSessionRequired)
139 def confirm(request):
140     """View handler for the eligibility verification form."""
141 
142     verifier = session.verifier(request)
143 
144     page = viewmodels.Page(
145         title=_(verifier.form_title),
146         content_title=_(verifier.form_content_title),
147         paragraphs=[_(verifier.form_blurb)],
148         form=forms.EligibilityVerificationForm(auto_id=True, label_suffix="", verifier=verifier),
149         classes="text-lg-center",
150     )
151 
152     if request.method == "POST":
153         analytics.started_eligibility(request)
154 
155         form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)
156         response = _verify(request, form)
157 
158         if response is None:
159             # form was not valid, allow for correction/resubmission
160             analytics.returned_error(request, form.errors)
161             page.forms = [form]
162             response = PageTemplateResponse(request, page)
163     elif session.eligible(request):
164         eligibility = session.eligibility(request)
165         response = verified(request, [eligibility.name])
166     else:
167         response = PageTemplateResponse(request, page)
168 
169     return response
170 
171 
172 def _verify(request, form):
173     """Helper calls the eligibility verification API with user input."""
174 
175     if not form.is_valid():
176         if recaptcha.has_error(form):
177             messages.error(request, "Recaptcha failed. Please try again.")
178         return None
179 
180     sub, name = form.cleaned_data.get("sub"), form.cleaned_data.get("name")
181 
182     agency = session.agency(request)
183     verifier = session.verifier(request)
184     client = api.Client(agency, verifier)
185 
186     response = client.verify(sub, name)
187 
188     if response.error and any(response.error):
189         form.add_api_errors(response.error)
190         return None
191     elif any(response.eligibility):
192         return verified(request, response.eligibility)
193     else:
194         return unverified(request)
195 
196 
197 @decorator_from_middleware(AgencySessionRequired)
198 @decorator_from_middleware(LoginRequired)
199 def verified(request, verified_types):
200     """View handler for the verified eligibility page."""
201 
202     analytics.returned_success(request)
203 
204     session.update(request, eligibility_types=verified_types)
205 
206     return redirect("enrollment:index")
207 
208 
209 @decorator_from_middleware(AgencySessionRequired)
210 @decorator_from_middleware(LoginRequired)
211 @decorator_from_middleware(VerifierSessionRequired)
212 def unverified(request):
213     """View handler for the unverified eligibility page."""
214 
215     analytics.returned_fail(request)
216 
217     # tel: link to agency phone number
218     agency = session.agency(request)
219     buttons = viewmodels.Button.agency_contact_links(agency)
220 
221     verifier = session.verifier(request)
222 
223     page = viewmodels.Page(
224         title=_(verifier.unverified_title),
225         content_title=_(verifier.unverified_content_title),
226         icon=viewmodels.Icon("idcardquestion", pgettext("image alt text", "core.icons.idcardquestion")),
227         paragraphs=[_(verifier.unverified_blurb), _("eligibility.pages.unverified.p[1]")],
228         buttons=buttons,
229         classes="text-lg-center",
230     )
231 
232     return PageTemplateResponse(request, page)
233
```
--- 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/views.py b/benefits/eligibility/views.py
--- a/benefits/eligibility/views.py
+++ b/benefits/eligibility/views.py
@@ -64,6 +64,8 @@
     verifier = session.verifier(request)
 
     button = viewmodels.Button.primary(text=_("eligibility.buttons.continue"), url=reverse("eligibility:confirm"))
+
+    payment_options_link = f"{reverse('core:help')}#payment-options"
     media = [
         dict(
             icon=viewmodels.Icon("idcardcheck", pgettext("image alt text", "core.icons.idcardcheck")),
@@ -72,18 +74,18 @@
         ),
         dict(
             icon=viewmodels.Icon("bankcardcheck", pgettext("image alt text", "core.icons.bankcardcheck")),
-            heading=_("eligibility.pages.start.items[1].title"),
-            details=_("eligibility.pages.start.items[1].text"),
+            heading=_("eligibility.pages.start.bankcard.title"),
+            details=_("eligibility.pages.start.bankcard.text"),
             links=[
                 viewmodels.Button.link(
                     classes="btn-text btn-link",
-                    text=_("eligibility.pages.start.items[1].button[0].link"),
-                    url=_("eligibility.pages.start.items[1].button[0].url"),
+                    text=_("eligibility.pages.start.bankcard.button[0].link"),
+                    url=payment_options_link,
                 ),
                 viewmodels.Button.link(
                     classes="btn-text btn-link",
-                    text=_("eligibility.pages.start.items[1].button[1].link"),
-                    url=_("eligibility.pages.start.items[1].button[1].url"),
+                    text=_("eligibility.pages.start.bankcard.button[1].link"),
+                    url=payment_options_link,
                 ),
             ],
         ),
@@ -93,18 +95,19 @@
         if settings.OAUTH_CLIENT_NAME is None:
             raise Exception("EligibilityVerifier requires authentication, but OAUTH_CLIENT_NAME is None")
 
+        oauth_help_link = f"{reverse('core:help')}#login-gov"
+
         media.insert(
             0,
             dict(
                 icon=viewmodels.Icon("idscreencheck", pgettext("image alt text", "core.icons.idscreencheck")),
-                heading=_("eligibility.media.heading"),
-                details=_("eligibility.media.details"),
+                heading=_("eligibility.pages.start.oauth.heading"),
+                details=_("eligibility.pages.start.oauth.details"),
                 links=[
                     viewmodels.Button.link(
                         classes="btn-text btn-link",
-                        text=_("eligibility.media.link_text"),
-                        url=_("eligibility.media.link_url"),
-                        target="_blank",
+                        text=_("eligibility.pages.start.oauth.link_text"),
+                        url=oauth_help_link,
                         rel="noopener noreferrer",
                     )
                 ],

{"golden_diff": "diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py\n--- a/benefits/eligibility/views.py\n+++ b/benefits/eligibility/views.py\n@@ -64,6 +64,8 @@\n     verifier = session.verifier(request)\n \n     button = viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(\"eligibility:confirm\"))\n+\n+    payment_options_link = f\"{reverse('core:help')}#payment-options\"\n     media = [\n         dict(\n             icon=viewmodels.Icon(\"idcardcheck\", pgettext(\"image alt text\", \"core.icons.idcardcheck\")),\n@@ -72,18 +74,18 @@\n         ),\n         dict(\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+            heading=_(\"eligibility.pages.start.bankcard.title\"),\n+            details=_(\"eligibility.pages.start.bankcard.text\"),\n             links=[\n                 viewmodels.Button.link(\n                     classes=\"btn-text btn-link\",\n-                    text=_(\"eligibility.pages.start.items[1].button[0].link\"),\n-                    url=_(\"eligibility.pages.start.items[1].button[0].url\"),\n+                    text=_(\"eligibility.pages.start.bankcard.button[0].link\"),\n+                    url=payment_options_link,\n                 ),\n                 viewmodels.Button.link(\n                     classes=\"btn-text btn-link\",\n-                    text=_(\"eligibility.pages.start.items[1].button[1].link\"),\n-                    url=_(\"eligibility.pages.start.items[1].button[1].url\"),\n+                    text=_(\"eligibility.pages.start.bankcard.button[1].link\"),\n+                    url=payment_options_link,\n                 ),\n             ],\n         ),\n@@ -93,18 +95,19 @@\n         if settings.OAUTH_CLIENT_NAME is None:\n             raise Exception(\"EligibilityVerifier requires authentication, but OAUTH_CLIENT_NAME is None\")\n \n+        oauth_help_link = f\"{reverse('core:help')}#login-gov\"\n+\n         media.insert(\n             0,\n             dict(\n                 icon=viewmodels.Icon(\"idscreencheck\", pgettext(\"image alt text\", \"core.icons.idscreencheck\")),\n-                heading=_(\"eligibility.media.heading\"),\n-                details=_(\"eligibility.media.details\"),\n+                heading=_(\"eligibility.pages.start.oauth.heading\"),\n+                details=_(\"eligibility.pages.start.oauth.details\"),\n                 links=[\n                     viewmodels.Button.link(\n                         classes=\"btn-text btn-link\",\n-                        text=_(\"eligibility.media.link_text\"),\n-                        url=_(\"eligibility.media.link_url\"),\n-                        target=\"_blank\",\n+                        text=_(\"eligibility.pages.start.oauth.link_text\"),\n+                        url=oauth_help_link,\n                         rel=\"noopener noreferrer\",\n                     )\n                 ],\n", "issue": "\"Learn more about Login.gov\" link should go to `/help#login-gov`\n### Steps to reproduce\r\nOn the `eligibility:start` page, click the \"Learn more about Login.gov\" link.\r\n\r\n### Expected result\r\nThe link goes to the \"What is Login.gov?\" section on the Help page.\r\n\r\n### Actual result\r\nThe link goes to `https://login.gov`.\r\n\n", "before_files": [{"content": "\"\"\"\nThe eligibility application: view definitions for the eligibility verification flow.\n\"\"\"\nfrom django.conf import settings\nfrom django.contrib import messages\nfrom django.shortcuts import redirect\nfrom django.template.response import TemplateResponse\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 recaptcha, session, viewmodels\nfrom benefits.core.middleware import AgencySessionRequired, LoginRequired, RateLimit, VerifierSessionRequired\nfrom benefits.core.models import EligibilityVerifier\nfrom benefits.core.views import PageTemplateResponse\nfrom . import analytics, api, forms\n\n\n@decorator_from_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    )\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(AgencySessionRequired)\n@decorator_from_middleware(VerifierSessionRequired)\ndef start(request):\n    \"\"\"View handler for the eligibility verification getting started screen.\"\"\"\n\n    session.update(request, eligibility_types=[], origin=reverse(\"eligibility:start\"))\n    verifier = session.verifier(request)\n\n    button = viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(\"eligibility:confirm\"))\n    media = [\n        dict(\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        dict(\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            links=[\n                viewmodels.Button.link(\n                    classes=\"btn-text btn-link\",\n                    text=_(\"eligibility.pages.start.items[1].button[0].link\"),\n                    url=_(\"eligibility.pages.start.items[1].button[0].url\"),\n                ),\n                viewmodels.Button.link(\n                    classes=\"btn-text btn-link\",\n                    text=_(\"eligibility.pages.start.items[1].button[1].link\"),\n                    url=_(\"eligibility.pages.start.items[1].button[1].url\"),\n                ),\n            ],\n        ),\n    ]\n\n    if verifier.requires_authentication:\n        if settings.OAUTH_CLIENT_NAME is None:\n            raise Exception(\"EligibilityVerifier requires authentication, but OAUTH_CLIENT_NAME is None\")\n\n        media.insert(\n            0,\n            dict(\n                icon=viewmodels.Icon(\"idscreencheck\", pgettext(\"image alt text\", \"core.icons.idscreencheck\")),\n                heading=_(\"eligibility.media.heading\"),\n                details=_(\"eligibility.media.details\"),\n                links=[\n                    viewmodels.Button.link(\n                        classes=\"btn-text btn-link\",\n                        text=_(\"eligibility.media.link_text\"),\n                        url=_(\"eligibility.media.link_url\"),\n                        target=\"_blank\",\n                        rel=\"noopener noreferrer\",\n                    )\n                ],\n            ),\n        )\n\n        if not session.logged_in(request):\n            button = viewmodels.Button.login(\n                label=_(verifier.auth_provider.sign_in_button_label),\n                text=\"\",\n                url=reverse(\"oauth:login\"),\n            )\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.start.title\"),\n        noimage=True,\n        paragraphs=[_(verifier.start_blurb)],\n        button=button,\n    )\n\n    ctx = page.context_dict()\n    ctx[\"title\"] = _(verifier.start_content_title)\n    ctx[\"media\"] = media\n\n    return TemplateResponse(request, \"eligibility/start.html\", ctx)\n\n\n@decorator_from_middleware(AgencySessionRequired)\n@decorator_from_middleware(LoginRequired)\n@decorator_from_middleware(RateLimit)\n@decorator_from_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(AgencySessionRequired)\n@decorator_from_middleware(LoginRequired)\ndef verified(request, verified_types):\n    \"\"\"View handler for the verified eligibility page.\"\"\"\n\n    analytics.returned_success(request)\n\n    session.update(request, eligibility_types=verified_types)\n\n    return redirect(\"enrollment:index\")\n\n\n@decorator_from_middleware(AgencySessionRequired)\n@decorator_from_middleware(LoginRequired)\n@decorator_from_middleware(VerifierSessionRequired)\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    verifier = session.verifier(request)\n\n    page = viewmodels.Page(\n        title=_(verifier.unverified_title),\n        content_title=_(verifier.unverified_content_title),\n        icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n        paragraphs=[_(verifier.unverified_blurb), _(\"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"}], "after_files": [{"content": "\"\"\"\nThe eligibility application: view definitions for the eligibility verification flow.\n\"\"\"\nfrom django.conf import settings\nfrom django.contrib import messages\nfrom django.shortcuts import redirect\nfrom django.template.response import TemplateResponse\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 recaptcha, session, viewmodels\nfrom benefits.core.middleware import AgencySessionRequired, LoginRequired, RateLimit, VerifierSessionRequired\nfrom benefits.core.models import EligibilityVerifier\nfrom benefits.core.views import PageTemplateResponse\nfrom . import analytics, api, forms\n\n\n@decorator_from_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    )\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(AgencySessionRequired)\n@decorator_from_middleware(VerifierSessionRequired)\ndef start(request):\n    \"\"\"View handler for the eligibility verification getting started screen.\"\"\"\n\n    session.update(request, eligibility_types=[], origin=reverse(\"eligibility:start\"))\n    verifier = session.verifier(request)\n\n    button = viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(\"eligibility:confirm\"))\n\n    payment_options_link = f\"{reverse('core:help')}#payment-options\"\n    media = [\n        dict(\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        dict(\n            icon=viewmodels.Icon(\"bankcardcheck\", pgettext(\"image alt text\", \"core.icons.bankcardcheck\")),\n            heading=_(\"eligibility.pages.start.bankcard.title\"),\n            details=_(\"eligibility.pages.start.bankcard.text\"),\n            links=[\n                viewmodels.Button.link(\n                    classes=\"btn-text btn-link\",\n                    text=_(\"eligibility.pages.start.bankcard.button[0].link\"),\n                    url=payment_options_link,\n                ),\n                viewmodels.Button.link(\n                    classes=\"btn-text btn-link\",\n                    text=_(\"eligibility.pages.start.bankcard.button[1].link\"),\n                    url=payment_options_link,\n                ),\n            ],\n        ),\n    ]\n\n    if verifier.requires_authentication:\n        if settings.OAUTH_CLIENT_NAME is None:\n            raise Exception(\"EligibilityVerifier requires authentication, but OAUTH_CLIENT_NAME is None\")\n\n        oauth_help_link = f\"{reverse('core:help')}#login-gov\"\n\n        media.insert(\n            0,\n            dict(\n                icon=viewmodels.Icon(\"idscreencheck\", pgettext(\"image alt text\", \"core.icons.idscreencheck\")),\n                heading=_(\"eligibility.pages.start.oauth.heading\"),\n                details=_(\"eligibility.pages.start.oauth.details\"),\n                links=[\n                    viewmodels.Button.link(\n                        classes=\"btn-text btn-link\",\n                        text=_(\"eligibility.pages.start.oauth.link_text\"),\n                        url=oauth_help_link,\n                        rel=\"noopener noreferrer\",\n                    )\n                ],\n            ),\n        )\n\n        if not session.logged_in(request):\n            button = viewmodels.Button.login(\n                label=_(verifier.auth_provider.sign_in_button_label),\n                text=\"\",\n                url=reverse(\"oauth:login\"),\n            )\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.start.title\"),\n        noimage=True,\n        paragraphs=[_(verifier.start_blurb)],\n        button=button,\n    )\n\n    ctx = page.context_dict()\n    ctx[\"title\"] = _(verifier.start_content_title)\n    ctx[\"media\"] = media\n\n    return TemplateResponse(request, \"eligibility/start.html\", ctx)\n\n\n@decorator_from_middleware(AgencySessionRequired)\n@decorator_from_middleware(LoginRequired)\n@decorator_from_middleware(RateLimit)\n@decorator_from_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(AgencySessionRequired)\n@decorator_from_middleware(LoginRequired)\ndef verified(request, verified_types):\n    \"\"\"View handler for the verified eligibility page.\"\"\"\n\n    analytics.returned_success(request)\n\n    session.update(request, eligibility_types=verified_types)\n\n    return redirect(\"enrollment:index\")\n\n\n@decorator_from_middleware(AgencySessionRequired)\n@decorator_from_middleware(LoginRequired)\n@decorator_from_middleware(VerifierSessionRequired)\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    verifier = session.verifier(request)\n\n    page = viewmodels.Page(\n        title=_(verifier.unverified_title),\n        content_title=_(verifier.unverified_content_title),\n        icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n        paragraphs=[_(verifier.unverified_blurb), _(\"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"}]}