We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Refactor "Agency links" include, page template
In #480 we introduced some new rendering for "Agency links" - the contact info phone number / website that shows up most notably on the Help page, but also when the user fails to verify their eligibility.

As a follow-up we should clean up the Page and Help templates so we aren't trying to do too much where it isn't needed.

## Tasks

* [x] The Back button should not be rendered in an include with agency links
* [x] The Page template should not render anything related to agency links
* [x] Create new template(s) for pages that do need to render agency links, using the include

--- 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.template.response import TemplateResponse
7 from django.urls import reverse
8 from django.utils.decorators import decorator_from_middleware
9 from django.utils.html import format_html
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 ROUTE_HELP
16 from . import analytics, forms, verify
17 
18 
19 ROUTE_INDEX = "eligibility:index"
20 ROUTE_START = "eligibility:start"
21 ROUTE_LOGIN = "oauth:login"
22 ROUTE_CONFIRM = "eligibility:confirm"
23 ROUTE_ENROLLMENT = "enrollment:index"
24 
25 TEMPLATE_INDEX = "eligibility/index.html"
26 TEMPLATE_START = "eligibility/start.html"
27 TEMPLATE_CONFIRM = "eligibility/confirm.html"
28 TEMPLATE_UNVERIFIED = "eligibility/unverified.html"
29 
30 
31 @decorator_from_middleware(AgencySessionRequired)
32 def index(request):
33     """View handler for the eligibility verifier selection form."""
34 
35     session.update(request, eligibility_types=[], origin=reverse(ROUTE_INDEX))
36     agency = session.agency(request)
37 
38     eligibility_start = reverse(ROUTE_START)
39 
40     help_page = reverse(ROUTE_HELP)
41 
42     page = viewmodels.Page(
43         title=_("eligibility.pages.index.title"),
44         headline=_("eligibility.pages.index.headline"),
45         paragraphs=[
46             format_html(_("eligibility.pages.index.p[0]%(info_link)s") % {"info_link": f"{help_page}#what-is-cal-itp"})
47         ],
48         forms=forms.EligibilityVerifierSelectionForm(agency=agency),
49     )
50 
51     ctx = page.context_dict()
52     ctx["help_page"] = help_page
53     ctx["help_text"] = format_html(
54         _("eligibility.pages.index.help_text%(help_link)s") % {"help_link": f"{help_page}#what-is-cal-itp"}
55     )
56 
57     if request.method == "POST":
58         form = forms.EligibilityVerifierSelectionForm(data=request.POST, agency=agency)
59 
60         if form.is_valid():
61             verifier_id = form.cleaned_data.get("verifier")
62             verifier = EligibilityVerifier.objects.get(id=verifier_id)
63             session.update(request, verifier=verifier)
64 
65             response = redirect(eligibility_start)
66         else:
67             # form was not valid, allow for correction/resubmission
68             page.forms = [form]
69             response = TemplateResponse(request, TEMPLATE_INDEX, ctx)
70     else:
71         if agency.eligibility_verifiers.count() == 1:
72             verifier = agency.eligibility_verifiers.first()
73             session.update(request, verifier=verifier)
74             response = redirect(eligibility_start)
75         else:
76             response = TemplateResponse(request, TEMPLATE_INDEX, ctx)
77 
78     return response
79 
80 
81 @decorator_from_middleware(AgencySessionRequired)
82 @decorator_from_middleware(VerifierSessionRequired)
83 def start(request):
84     """View handler for the eligibility verification getting started screen."""
85 
86     verifier = session.verifier(request)
87     button = viewmodels.Button.primary(text=_("eligibility.buttons.continue"), url=reverse(ROUTE_CONFIRM))
88 
89     # define the verifier-specific required item
90     identity_item = viewmodels.MediaItem(
91         icon=viewmodels.Icon("idcardcheck", pgettext("image alt text", "core.icons.idcardcheck")),
92         heading=_(verifier.start_item_name),
93         details=_(verifier.start_item_description),
94     )
95 
96     if verifier.is_auth_required:
97         if verifier.uses_auth_verification:
98             identity_item.bullets = [
99                 _("eligibility.pages.start.mst_login.required_items[0]"),
100                 _("eligibility.pages.start.mst_login.required_items[1]"),
101                 _("eligibility.pages.start.mst_login.required_items[2]"),
102             ]
103 
104         if not session.logged_in(request):
105             button = viewmodels.Button.login(
106                 text=_(verifier.auth_provider.sign_in_button_label),
107                 url=reverse(ROUTE_LOGIN),
108             )
109 
110     # define the bank card item
111     bank_card_item = viewmodels.MediaItem(
112         icon=viewmodels.Icon("bankcardcheck", pgettext("image alt text", "core.icons.bankcardcheck")),
113         heading=_("eligibility.pages.start.bankcard.title"),
114         details=_("eligibility.pages.start.bankcard.text"),
115     )
116 
117     media = [identity_item, bank_card_item]
118 
119     page = viewmodels.Page(
120         title=_("eligibility.pages.start.title"),
121         headline=_(verifier.start_headline),
122         paragraphs=[_(verifier.start_blurb)],
123         button=button,
124     )
125 
126     ctx = page.context_dict()
127     ctx["previous_page_button"] = viewmodels.Button.previous_page(url=reverse(ROUTE_INDEX))
128     ctx["start_sub_headline"] = _(verifier.start_sub_headline)
129     ctx["media"] = media
130     ctx["help_link"] = reverse(ROUTE_HELP)
131 
132     # update origin now, after we've saved the previous page
133     session.update(request, eligibility_types=[], origin=reverse(ROUTE_START))
134 
135     return TemplateResponse(request, TEMPLATE_START, ctx)
136 
137 
138 @decorator_from_middleware(AgencySessionRequired)
139 @decorator_from_middleware(LoginRequired)
140 @decorator_from_middleware(RateLimit)
141 @decorator_from_middleware(VerifierSessionRequired)
142 def confirm(request):
143     """View handler for the eligibility verification form."""
144 
145     # GET from an already verified user, no need to verify again
146     if request.method == "GET" and session.eligible(request):
147         eligibility = session.eligibility(request)
148         return verified(request, [eligibility.name])
149 
150     agency = session.agency(request)
151     verifier = session.verifier(request)
152     types_to_verify = verify.typenames_to_verify(agency, verifier)
153 
154     # GET for OAuth verification
155     if request.method == "GET" and verifier.uses_auth_verification:
156         analytics.started_eligibility(request, types_to_verify)
157 
158         verified_types = verify.eligibility_from_oauth(verifier, session.oauth_claim(request), agency)
159         if verified_types:
160             return verified(request, verified_types)
161         else:
162             return unverified(request)
163 
164     # GET/POST for Eligibility API verification
165     page = viewmodels.Page(
166         title=_(verifier.form_title),
167         headline=_(verifier.form_headline),
168         paragraphs=[_(verifier.form_blurb)],
169         form=forms.EligibilityVerificationForm(auto_id=True, label_suffix="", verifier=verifier),
170     )
171 
172     ctx = page.context_dict()
173     ctx["previous_page_button"] = viewmodels.Button.previous_page(url=reverse(ROUTE_START))
174 
175     # GET from an unverified user, present the form
176     if request.method == "GET":
177         return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)
178     # POST form submission, process form data, make Eligibility Verification API call
179     elif request.method == "POST":
180         analytics.started_eligibility(request, types_to_verify)
181 
182         form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)
183         # form was not valid, allow for correction/resubmission
184         if not form.is_valid():
185             if recaptcha.has_error(form):
186                 messages.error(request, "Recaptcha failed. Please try again.")
187 
188             page.forms = [form]
189             ctx.update(page.context_dict())
190             return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)
191 
192         # form is valid, make Eligibility Verification request to get the verified types
193         verified_types = verify.eligibility_from_api(verifier, form, agency)
194 
195         # form was not valid, allow for correction/resubmission
196         if verified_types is None:
197             analytics.returned_error(request, types_to_verify, form.errors)
198             page.forms = [form]
199             ctx.update(page.context_dict())
200             return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)
201         # no types were verified
202         elif len(verified_types) == 0:
203             return unverified(request)
204         # type(s) were verified
205         else:
206             return verified(request, verified_types)
207 
208 
209 @decorator_from_middleware(AgencySessionRequired)
210 @decorator_from_middleware(LoginRequired)
211 def verified(request, verified_types):
212     """View handler for the verified eligibility page."""
213 
214     analytics.returned_success(request, verified_types)
215 
216     session.update(request, eligibility_types=verified_types)
217 
218     return redirect(ROUTE_ENROLLMENT)
219 
220 
221 @decorator_from_middleware(AgencySessionRequired)
222 @decorator_from_middleware(VerifierSessionRequired)
223 def unverified(request):
224     """View handler for the unverified eligibility page."""
225 
226     agency = session.agency(request)
227     verifier = session.verifier(request)
228     types_to_verify = verify.typenames_to_verify(agency, verifier)
229 
230     analytics.returned_fail(request, types_to_verify)
231 
232     # tel: link to agency phone number
233     buttons = viewmodels.Button.agency_contact_links(agency)
234     buttons.append(viewmodels.Button.home(request))
235 
236     page = viewmodels.Page(
237         title=_(verifier.unverified_title),
238         classes="with-agency-links",
239         headline=_(verifier.unverified_headline),
240         icon=viewmodels.Icon("idcardquestion", pgettext("image alt text", "core.icons.idcardquestion")),
241         paragraphs=[_(verifier.unverified_blurb)],
242         buttons=buttons,
243     )
244 
245     return TemplateResponse(request, TEMPLATE_UNVERIFIED, page.context_dict())
246
```
--- 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
@@ -235,7 +235,6 @@
 
     page = viewmodels.Page(
         title=_(verifier.unverified_title),
-        classes="with-agency-links",
         headline=_(verifier.unverified_headline),
         icon=viewmodels.Icon("idcardquestion", pgettext("image alt text", "core.icons.idcardquestion")),
         paragraphs=[_(verifier.unverified_blurb)],

{"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@@ -235,7 +235,6 @@\n \n     page = viewmodels.Page(\n         title=_(verifier.unverified_title),\n-        classes=\"with-agency-links\",\n         headline=_(verifier.unverified_headline),\n         icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n         paragraphs=[_(verifier.unverified_blurb)],\n", "issue": "Refactor \"Agency links\" include, page template\nIn #480 we introduced some new rendering for \"Agency links\" - the contact info phone number / website that shows up most notably on the Help page, but also when the user fails to verify their eligibility.\r\n\r\nAs a follow-up we should clean up the Page and Help templates so we aren't trying to do too much where it isn't needed.\r\n\r\n## Tasks\r\n\r\n* [x] The Back button should not be rendered in an include with agency links\r\n* [x] The Page template should not render anything related to agency links\r\n* [x] Create new template(s) for pages that do need to render agency links, using the include\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.template.response import TemplateResponse\nfrom django.urls import reverse\nfrom django.utils.decorators import decorator_from_middleware\nfrom django.utils.html import format_html\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 ROUTE_HELP\nfrom . import analytics, forms, verify\n\n\nROUTE_INDEX = \"eligibility:index\"\nROUTE_START = \"eligibility:start\"\nROUTE_LOGIN = \"oauth:login\"\nROUTE_CONFIRM = \"eligibility:confirm\"\nROUTE_ENROLLMENT = \"enrollment:index\"\n\nTEMPLATE_INDEX = \"eligibility/index.html\"\nTEMPLATE_START = \"eligibility/start.html\"\nTEMPLATE_CONFIRM = \"eligibility/confirm.html\"\nTEMPLATE_UNVERIFIED = \"eligibility/unverified.html\"\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(ROUTE_INDEX))\n    agency = session.agency(request)\n\n    eligibility_start = reverse(ROUTE_START)\n\n    help_page = reverse(ROUTE_HELP)\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.index.title\"),\n        headline=_(\"eligibility.pages.index.headline\"),\n        paragraphs=[\n            format_html(_(\"eligibility.pages.index.p[0]%(info_link)s\") % {\"info_link\": f\"{help_page}#what-is-cal-itp\"})\n        ],\n        forms=forms.EligibilityVerifierSelectionForm(agency=agency),\n    )\n\n    ctx = page.context_dict()\n    ctx[\"help_page\"] = help_page\n    ctx[\"help_text\"] = format_html(\n        _(\"eligibility.pages.index.help_text%(help_link)s\") % {\"help_link\": f\"{help_page}#what-is-cal-itp\"}\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 = TemplateResponse(request, TEMPLATE_INDEX, ctx)\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 = TemplateResponse(request, TEMPLATE_INDEX, ctx)\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    verifier = session.verifier(request)\n    button = viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(ROUTE_CONFIRM))\n\n    # define the verifier-specific required item\n    identity_item = 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\n    if verifier.is_auth_required:\n        if verifier.uses_auth_verification:\n            identity_item.bullets = [\n                _(\"eligibility.pages.start.mst_login.required_items[0]\"),\n                _(\"eligibility.pages.start.mst_login.required_items[1]\"),\n                _(\"eligibility.pages.start.mst_login.required_items[2]\"),\n            ]\n\n        if not session.logged_in(request):\n            button = viewmodels.Button.login(\n                text=_(verifier.auth_provider.sign_in_button_label),\n                url=reverse(ROUTE_LOGIN),\n            )\n\n    # define the bank card item\n    bank_card_item = viewmodels.MediaItem(\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    )\n\n    media = [identity_item, bank_card_item]\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.start.title\"),\n        headline=_(verifier.start_headline),\n        paragraphs=[_(verifier.start_blurb)],\n        button=button,\n    )\n\n    ctx = page.context_dict()\n    ctx[\"previous_page_button\"] = viewmodels.Button.previous_page(url=reverse(ROUTE_INDEX))\n    ctx[\"start_sub_headline\"] = _(verifier.start_sub_headline)\n    ctx[\"media\"] = media\n    ctx[\"help_link\"] = reverse(ROUTE_HELP)\n\n    # update origin now, after we've saved the previous page\n    session.update(request, eligibility_types=[], origin=reverse(ROUTE_START))\n\n    return TemplateResponse(request, TEMPLATE_START, 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    # GET from an already verified user, no need to verify again\n    if request.method == \"GET\" and session.eligible(request):\n        eligibility = session.eligibility(request)\n        return verified(request, [eligibility.name])\n\n    agency = session.agency(request)\n    verifier = session.verifier(request)\n    types_to_verify = verify.typenames_to_verify(agency, verifier)\n\n    # GET for OAuth verification\n    if request.method == \"GET\" and verifier.uses_auth_verification:\n        analytics.started_eligibility(request, types_to_verify)\n\n        verified_types = verify.eligibility_from_oauth(verifier, session.oauth_claim(request), agency)\n        if verified_types:\n            return verified(request, verified_types)\n        else:\n            return unverified(request)\n\n    # GET/POST for Eligibility API verification\n    page = viewmodels.Page(\n        title=_(verifier.form_title),\n        headline=_(verifier.form_headline),\n        paragraphs=[_(verifier.form_blurb)],\n        form=forms.EligibilityVerificationForm(auto_id=True, label_suffix=\"\", verifier=verifier),\n    )\n\n    ctx = page.context_dict()\n    ctx[\"previous_page_button\"] = viewmodels.Button.previous_page(url=reverse(ROUTE_START))\n\n    # GET from an unverified user, present the form\n    if request.method == \"GET\":\n        return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)\n    # POST form submission, process form data, make Eligibility Verification API call\n    elif request.method == \"POST\":\n        analytics.started_eligibility(request, types_to_verify)\n\n        form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)\n        # form was not valid, allow for correction/resubmission\n        if not form.is_valid():\n            if recaptcha.has_error(form):\n                messages.error(request, \"Recaptcha failed. Please try again.\")\n\n            page.forms = [form]\n            ctx.update(page.context_dict())\n            return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)\n\n        # form is valid, make Eligibility Verification request to get the verified types\n        verified_types = verify.eligibility_from_api(verifier, form, agency)\n\n        # form was not valid, allow for correction/resubmission\n        if verified_types is None:\n            analytics.returned_error(request, types_to_verify, form.errors)\n            page.forms = [form]\n            ctx.update(page.context_dict())\n            return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)\n        # no types were verified\n        elif len(verified_types) == 0:\n            return unverified(request)\n        # type(s) were verified\n        else:\n            return verified(request, verified_types)\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, verified_types)\n\n    session.update(request, eligibility_types=verified_types)\n\n    return redirect(ROUTE_ENROLLMENT)\n\n\n@decorator_from_middleware(AgencySessionRequired)\n@decorator_from_middleware(VerifierSessionRequired)\ndef unverified(request):\n    \"\"\"View handler for the unverified eligibility page.\"\"\"\n\n    agency = session.agency(request)\n    verifier = session.verifier(request)\n    types_to_verify = verify.typenames_to_verify(agency, verifier)\n\n    analytics.returned_fail(request, types_to_verify)\n\n    # tel: link to agency phone number\n    buttons = viewmodels.Button.agency_contact_links(agency)\n    buttons.append(viewmodels.Button.home(request))\n\n    page = viewmodels.Page(\n        title=_(verifier.unverified_title),\n        classes=\"with-agency-links\",\n        headline=_(verifier.unverified_headline),\n        icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n        paragraphs=[_(verifier.unverified_blurb)],\n        buttons=buttons,\n    )\n\n    return TemplateResponse(request, TEMPLATE_UNVERIFIED, page.context_dict())\n", "path": "benefits/eligibility/views.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.template.response import TemplateResponse\nfrom django.urls import reverse\nfrom django.utils.decorators import decorator_from_middleware\nfrom django.utils.html import format_html\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 ROUTE_HELP\nfrom . import analytics, forms, verify\n\n\nROUTE_INDEX = \"eligibility:index\"\nROUTE_START = \"eligibility:start\"\nROUTE_LOGIN = \"oauth:login\"\nROUTE_CONFIRM = \"eligibility:confirm\"\nROUTE_ENROLLMENT = \"enrollment:index\"\n\nTEMPLATE_INDEX = \"eligibility/index.html\"\nTEMPLATE_START = \"eligibility/start.html\"\nTEMPLATE_CONFIRM = \"eligibility/confirm.html\"\nTEMPLATE_UNVERIFIED = \"eligibility/unverified.html\"\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(ROUTE_INDEX))\n    agency = session.agency(request)\n\n    eligibility_start = reverse(ROUTE_START)\n\n    help_page = reverse(ROUTE_HELP)\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.index.title\"),\n        headline=_(\"eligibility.pages.index.headline\"),\n        paragraphs=[\n            format_html(_(\"eligibility.pages.index.p[0]%(info_link)s\") % {\"info_link\": f\"{help_page}#what-is-cal-itp\"})\n        ],\n        forms=forms.EligibilityVerifierSelectionForm(agency=agency),\n    )\n\n    ctx = page.context_dict()\n    ctx[\"help_page\"] = help_page\n    ctx[\"help_text\"] = format_html(\n        _(\"eligibility.pages.index.help_text%(help_link)s\") % {\"help_link\": f\"{help_page}#what-is-cal-itp\"}\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 = TemplateResponse(request, TEMPLATE_INDEX, ctx)\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 = TemplateResponse(request, TEMPLATE_INDEX, ctx)\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    verifier = session.verifier(request)\n    button = viewmodels.Button.primary(text=_(\"eligibility.buttons.continue\"), url=reverse(ROUTE_CONFIRM))\n\n    # define the verifier-specific required item\n    identity_item = 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\n    if verifier.is_auth_required:\n        if verifier.uses_auth_verification:\n            identity_item.bullets = [\n                _(\"eligibility.pages.start.mst_login.required_items[0]\"),\n                _(\"eligibility.pages.start.mst_login.required_items[1]\"),\n                _(\"eligibility.pages.start.mst_login.required_items[2]\"),\n            ]\n\n        if not session.logged_in(request):\n            button = viewmodels.Button.login(\n                text=_(verifier.auth_provider.sign_in_button_label),\n                url=reverse(ROUTE_LOGIN),\n            )\n\n    # define the bank card item\n    bank_card_item = viewmodels.MediaItem(\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    )\n\n    media = [identity_item, bank_card_item]\n\n    page = viewmodels.Page(\n        title=_(\"eligibility.pages.start.title\"),\n        headline=_(verifier.start_headline),\n        paragraphs=[_(verifier.start_blurb)],\n        button=button,\n    )\n\n    ctx = page.context_dict()\n    ctx[\"previous_page_button\"] = viewmodels.Button.previous_page(url=reverse(ROUTE_INDEX))\n    ctx[\"start_sub_headline\"] = _(verifier.start_sub_headline)\n    ctx[\"media\"] = media\n    ctx[\"help_link\"] = reverse(ROUTE_HELP)\n\n    # update origin now, after we've saved the previous page\n    session.update(request, eligibility_types=[], origin=reverse(ROUTE_START))\n\n    return TemplateResponse(request, TEMPLATE_START, 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    # GET from an already verified user, no need to verify again\n    if request.method == \"GET\" and session.eligible(request):\n        eligibility = session.eligibility(request)\n        return verified(request, [eligibility.name])\n\n    agency = session.agency(request)\n    verifier = session.verifier(request)\n    types_to_verify = verify.typenames_to_verify(agency, verifier)\n\n    # GET for OAuth verification\n    if request.method == \"GET\" and verifier.uses_auth_verification:\n        analytics.started_eligibility(request, types_to_verify)\n\n        verified_types = verify.eligibility_from_oauth(verifier, session.oauth_claim(request), agency)\n        if verified_types:\n            return verified(request, verified_types)\n        else:\n            return unverified(request)\n\n    # GET/POST for Eligibility API verification\n    page = viewmodels.Page(\n        title=_(verifier.form_title),\n        headline=_(verifier.form_headline),\n        paragraphs=[_(verifier.form_blurb)],\n        form=forms.EligibilityVerificationForm(auto_id=True, label_suffix=\"\", verifier=verifier),\n    )\n\n    ctx = page.context_dict()\n    ctx[\"previous_page_button\"] = viewmodels.Button.previous_page(url=reverse(ROUTE_START))\n\n    # GET from an unverified user, present the form\n    if request.method == \"GET\":\n        return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)\n    # POST form submission, process form data, make Eligibility Verification API call\n    elif request.method == \"POST\":\n        analytics.started_eligibility(request, types_to_verify)\n\n        form = forms.EligibilityVerificationForm(data=request.POST, verifier=verifier)\n        # form was not valid, allow for correction/resubmission\n        if not form.is_valid():\n            if recaptcha.has_error(form):\n                messages.error(request, \"Recaptcha failed. Please try again.\")\n\n            page.forms = [form]\n            ctx.update(page.context_dict())\n            return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)\n\n        # form is valid, make Eligibility Verification request to get the verified types\n        verified_types = verify.eligibility_from_api(verifier, form, agency)\n\n        # form was not valid, allow for correction/resubmission\n        if verified_types is None:\n            analytics.returned_error(request, types_to_verify, form.errors)\n            page.forms = [form]\n            ctx.update(page.context_dict())\n            return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)\n        # no types were verified\n        elif len(verified_types) == 0:\n            return unverified(request)\n        # type(s) were verified\n        else:\n            return verified(request, verified_types)\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, verified_types)\n\n    session.update(request, eligibility_types=verified_types)\n\n    return redirect(ROUTE_ENROLLMENT)\n\n\n@decorator_from_middleware(AgencySessionRequired)\n@decorator_from_middleware(VerifierSessionRequired)\ndef unverified(request):\n    \"\"\"View handler for the unverified eligibility page.\"\"\"\n\n    agency = session.agency(request)\n    verifier = session.verifier(request)\n    types_to_verify = verify.typenames_to_verify(agency, verifier)\n\n    analytics.returned_fail(request, types_to_verify)\n\n    # tel: link to agency phone number\n    buttons = viewmodels.Button.agency_contact_links(agency)\n    buttons.append(viewmodels.Button.home(request))\n\n    page = viewmodels.Page(\n        title=_(verifier.unverified_title),\n        headline=_(verifier.unverified_headline),\n        icon=viewmodels.Icon(\"idcardquestion\", pgettext(\"image alt text\", \"core.icons.idcardquestion\")),\n        paragraphs=[_(verifier.unverified_blurb)],\n        buttons=buttons,\n    )\n\n    return TemplateResponse(request, TEMPLATE_UNVERIFIED, page.context_dict())\n", "path": "benefits/eligibility/views.py"}]}