prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Refactor Agency dynamic headline into model prop
  Right now we are hardcoding the [Agency index headline PO key](https://github.com/cal-itp/benefits/blob/dev/benefits/core/views.py#L62):
  
  ```python
  page = viewmodels.Page(
        title=_("core.pages.agency_index.title"),
        headline=_("core.pages.agency_index.mst_cc.headline"),
        button=button,
        classes="home",
    )
  ```
  
  This is fine for MST. We need to make this a dynamic key coming from an `agency` prop for the future.
  
  ## Acceptance Criteria
  
  <!-- Remember to consider edge cases -->
  
  - [ ] `agency_index` gets its headline from the selected `agency`
  
  
  --- 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/core/views.py`
  Content:
  ```
  1 """
  2 The core application: view definition for the root of the webapp.
  3 """
  4 from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound, HttpResponseServerError
  5 from django.template import loader
  6 from django.template.response import TemplateResponse
  7 from django.urls import reverse
  8 from django.utils.translation import pgettext, gettext as _
  9 
  10 from . import models, session, viewmodels
  11 from .middleware import pageview_decorator
  12 
  13 ROUTE_INDEX = "core:index"
  14 ROUTE_ELIGIBILITY = "eligibility:index"
  15 ROUTE_HELP = "core:help"
  16 ROUTE_LOGGED_OUT = "core:logged_out"
  17 
  18 TEMPLATE_INDEX = "core/index.html"
  19 TEMPLATE_AGENCY = "core/agency_index.html"
  20 TEMPLATE_HELP = "core/help.html"
  21 TEMPLATE_LOGGED_OUT = "core/logged_out.html"
  22 
  23 
  24 @pageview_decorator
  25 def index(request):
  26     """View handler for the main entry page."""
  27     session.reset(request)
  28 
  29     page = viewmodels.Page(
  30         title=_("core.pages.index.title"),
  31         headline=_("core.pages.index.headline"),
  32         modal=viewmodels.AgencySelector(
  33             id="agency-selector",
  34             aria_labelledby_id="agency-selector-modal-label",
  35             button_text=_("core.pages.index.button"),
  36         ),
  37     )
  38 
  39     return TemplateResponse(request, TEMPLATE_INDEX, page.context_dict())
  40 
  41 
  42 @pageview_decorator
  43 def agency_index(request, agency):
  44     """View handler for an agency entry page."""
  45     session.reset(request)
  46     session.update(request, agency=agency, origin=agency.index_url)
  47 
  48     button = viewmodels.Button.primary(text=_("core.pages.index.continue"), url=reverse(ROUTE_ELIGIBILITY))
  49 
  50     page = viewmodels.Page(
  51         title=_("core.pages.agency_index.title"),
  52         headline=_("core.pages.agency_index.mst_cc.headline"),
  53         button=button,
  54     )
  55 
  56     return TemplateResponse(request, TEMPLATE_AGENCY, page.context_dict())
  57 
  58 
  59 @pageview_decorator
  60 def agency_public_key(request, agency):
  61     """View handler returns an agency's public key as plain text."""
  62     return HttpResponse(agency.public_key_data, content_type="text/plain")
  63 
  64 
  65 @pageview_decorator
  66 def help(request):
  67     """View handler for the help page."""
  68     if session.active_agency(request):
  69         agency = session.agency(request)
  70         buttons = viewmodels.Button.agency_contact_links(agency)
  71     else:
  72         buttons = [btn for a in models.TransitAgency.all_active() for btn in viewmodels.Button.agency_contact_links(a)]
  73 
  74     buttons.append(viewmodels.Button.home(request, _("core.buttons.back")))
  75 
  76     page = viewmodels.Page(
  77         title=_("core.buttons.help"),
  78         headline=_("core.buttons.help"),
  79         buttons=buttons,
  80     )
  81 
  82     return TemplateResponse(request, TEMPLATE_HELP, page.context_dict())
  83 
  84 
  85 @pageview_decorator
  86 def bad_request(request, exception, template_name="400.html"):
  87     """View handler for HTTP 400 Bad Request responses."""
  88     if session.active_agency(request):
  89         session.update(request, origin=session.agency(request).index_url)
  90     else:
  91         session.update(request, origin=reverse(ROUTE_INDEX))
  92 
  93     home = viewmodels.Button.home(request)
  94     page = viewmodels.ErrorPage.server_error(button=home)
  95     t = loader.get_template(template_name)
  96 
  97     return HttpResponseBadRequest(t.render(page.context_dict()))
  98 
  99 
  100 @pageview_decorator
  101 def csrf_failure(request, reason):
  102     """
  103     View handler for CSRF_FAILURE_VIEW with custom data.
  104     """
  105     if session.active_agency(request):
  106         session.update(request, origin=session.agency(request).index_url)
  107     else:
  108         session.update(request, origin=reverse(ROUTE_INDEX))
  109 
  110     home = viewmodels.Button.home(request)
  111     page = viewmodels.ErrorPage.not_found(button=home, path=request.path)
  112     t = loader.get_template("400.html")
  113 
  114     return HttpResponseNotFound(t.render(page.context_dict()))
  115 
  116 
  117 @pageview_decorator
  118 def page_not_found(request, exception, template_name="404.html"):
  119     """View handler for HTTP 404 Not Found responses."""
  120     if session.active_agency(request):
  121         session.update(request, origin=session.agency(request).index_url)
  122     else:
  123         session.update(request, origin=reverse(ROUTE_INDEX))
  124 
  125     home = viewmodels.Button.home(request)
  126     # show a more user-friendly message instead of not_found
  127     page = viewmodels.ErrorPage.user_error(button=home, path=request.path)
  128     t = loader.get_template(template_name)
  129 
  130     return HttpResponseNotFound(t.render(page.context_dict()))
  131 
  132 
  133 @pageview_decorator
  134 def server_error(request, template_name="500.html"):
  135     """View handler for HTTP 500 Server Error responses."""
  136     if session.active_agency(request):
  137         session.update(request, origin=session.agency(request).index_url)
  138     else:
  139         session.update(request, origin=reverse(ROUTE_INDEX))
  140 
  141     home = viewmodels.Button.home(request)
  142     page = viewmodels.ErrorPage.server_error(button=home)
  143     t = loader.get_template(template_name)
  144 
  145     return HttpResponseServerError(t.render(page.context_dict()))
  146 
  147 
  148 def logged_out(request):
  149     """View handler for the final log out confirmation message."""
  150     page = viewmodels.Page(
  151         title=_("core.pages.logged_out.title"),
  152         icon=viewmodels.Icon("happybus", pgettext("image alt text", "core.icons.happybus")),
  153     )
  154 
  155     return TemplateResponse(request, TEMPLATE_LOGGED_OUT, page.context_dict())
  156
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/benefits/core/views.py b/benefits/core/views.py
  --- a/benefits/core/views.py
  +++ b/benefits/core/views.py
  @@ -49,7 +49,8 @@
   
       page = viewmodels.Page(
           title=_("core.pages.agency_index.title"),
  -        headline=_("core.pages.agency_index.mst_cc.headline"),
  +        headline=_("core.pages.agency_index.headline%(transit_agency_short_name)s")
  +        % {"transit_agency_short_name": agency.short_name},
           button=button,
       )
  
verification_info: {"golden_diff": "diff --git a/benefits/core/views.py b/benefits/core/views.py\n--- a/benefits/core/views.py\n+++ b/benefits/core/views.py\n@@ -49,7 +49,8 @@\n \n     page = viewmodels.Page(\n         title=_(\"core.pages.agency_index.title\"),\n-        headline=_(\"core.pages.agency_index.mst_cc.headline\"),\n+        headline=_(\"core.pages.agency_index.headline%(transit_agency_short_name)s\")\n+        % {\"transit_agency_short_name\": agency.short_name},\n         button=button,\n     )\n", "issue": "Refactor Agency dynamic headline into model prop\nRight now we are hardcoding the [Agency index headline PO key](https://github.com/cal-itp/benefits/blob/dev/benefits/core/views.py#L62):\r\n\r\n```python\r\npage = viewmodels.Page(\r\n      title=_(\"core.pages.agency_index.title\"),\r\n      headline=_(\"core.pages.agency_index.mst_cc.headline\"),\r\n      button=button,\r\n      classes=\"home\",\r\n  )\r\n```\r\n\r\nThis is fine for MST. We need to make this a dynamic key coming from an `agency` prop for the future.\r\n\r\n## Acceptance Criteria\r\n\r\n<!-- Remember to consider edge cases -->\r\n\r\n- [ ] `agency_index` gets its headline from the selected `agency`\r\n\n", "before_files": [{"content": "\"\"\"\nThe core application: view definition for the root of the webapp.\n\"\"\"\nfrom django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound, HttpResponseServerError\nfrom django.template import loader\nfrom django.template.response import TemplateResponse\nfrom django.urls import reverse\nfrom django.utils.translation import pgettext, gettext as _\n\nfrom . import models, session, viewmodels\nfrom .middleware import pageview_decorator\n\nROUTE_INDEX = \"core:index\"\nROUTE_ELIGIBILITY = \"eligibility:index\"\nROUTE_HELP = \"core:help\"\nROUTE_LOGGED_OUT = \"core:logged_out\"\n\nTEMPLATE_INDEX = \"core/index.html\"\nTEMPLATE_AGENCY = \"core/agency_index.html\"\nTEMPLATE_HELP = \"core/help.html\"\nTEMPLATE_LOGGED_OUT = \"core/logged_out.html\"\n\n\n@pageview_decorator\ndef index(request):\n    \"\"\"View handler for the main entry page.\"\"\"\n    session.reset(request)\n\n    page = viewmodels.Page(\n        title=_(\"core.pages.index.title\"),\n        headline=_(\"core.pages.index.headline\"),\n        modal=viewmodels.AgencySelector(\n            id=\"agency-selector\",\n            aria_labelledby_id=\"agency-selector-modal-label\",\n            button_text=_(\"core.pages.index.button\"),\n        ),\n    )\n\n    return TemplateResponse(request, TEMPLATE_INDEX, page.context_dict())\n\n\n@pageview_decorator\ndef agency_index(request, agency):\n    \"\"\"View handler for an agency entry page.\"\"\"\n    session.reset(request)\n    session.update(request, agency=agency, origin=agency.index_url)\n\n    button = viewmodels.Button.primary(text=_(\"core.pages.index.continue\"), url=reverse(ROUTE_ELIGIBILITY))\n\n    page = viewmodels.Page(\n        title=_(\"core.pages.agency_index.title\"),\n        headline=_(\"core.pages.agency_index.mst_cc.headline\"),\n        button=button,\n    )\n\n    return TemplateResponse(request, TEMPLATE_AGENCY, page.context_dict())\n\n\n@pageview_decorator\ndef agency_public_key(request, agency):\n    \"\"\"View handler returns an agency's public key as plain text.\"\"\"\n    return HttpResponse(agency.public_key_data, content_type=\"text/plain\")\n\n\n@pageview_decorator\ndef help(request):\n    \"\"\"View handler for the help page.\"\"\"\n    if session.active_agency(request):\n        agency = session.agency(request)\n        buttons = viewmodels.Button.agency_contact_links(agency)\n    else:\n        buttons = [btn for a in models.TransitAgency.all_active() for btn in viewmodels.Button.agency_contact_links(a)]\n\n    buttons.append(viewmodels.Button.home(request, _(\"core.buttons.back\")))\n\n    page = viewmodels.Page(\n        title=_(\"core.buttons.help\"),\n        headline=_(\"core.buttons.help\"),\n        buttons=buttons,\n    )\n\n    return TemplateResponse(request, TEMPLATE_HELP, page.context_dict())\n\n\n@pageview_decorator\ndef bad_request(request, exception, template_name=\"400.html\"):\n    \"\"\"View handler for HTTP 400 Bad Request responses.\"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    page = viewmodels.ErrorPage.server_error(button=home)\n    t = loader.get_template(template_name)\n\n    return HttpResponseBadRequest(t.render(page.context_dict()))\n\n\n@pageview_decorator\ndef csrf_failure(request, reason):\n    \"\"\"\n    View handler for CSRF_FAILURE_VIEW with custom data.\n    \"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    page = viewmodels.ErrorPage.not_found(button=home, path=request.path)\n    t = loader.get_template(\"400.html\")\n\n    return HttpResponseNotFound(t.render(page.context_dict()))\n\n\n@pageview_decorator\ndef page_not_found(request, exception, template_name=\"404.html\"):\n    \"\"\"View handler for HTTP 404 Not Found responses.\"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    # show a more user-friendly message instead of not_found\n    page = viewmodels.ErrorPage.user_error(button=home, path=request.path)\n    t = loader.get_template(template_name)\n\n    return HttpResponseNotFound(t.render(page.context_dict()))\n\n\n@pageview_decorator\ndef server_error(request, template_name=\"500.html\"):\n    \"\"\"View handler for HTTP 500 Server Error responses.\"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    page = viewmodels.ErrorPage.server_error(button=home)\n    t = loader.get_template(template_name)\n\n    return HttpResponseServerError(t.render(page.context_dict()))\n\n\ndef logged_out(request):\n    \"\"\"View handler for the final log out confirmation message.\"\"\"\n    page = viewmodels.Page(\n        title=_(\"core.pages.logged_out.title\"),\n        icon=viewmodels.Icon(\"happybus\", pgettext(\"image alt text\", \"core.icons.happybus\")),\n    )\n\n    return TemplateResponse(request, TEMPLATE_LOGGED_OUT, page.context_dict())\n", "path": "benefits/core/views.py"}], "after_files": [{"content": "\"\"\"\nThe core application: view definition for the root of the webapp.\n\"\"\"\nfrom django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound, HttpResponseServerError\nfrom django.template import loader\nfrom django.template.response import TemplateResponse\nfrom django.urls import reverse\nfrom django.utils.translation import pgettext, gettext as _\n\nfrom . import models, session, viewmodels\nfrom .middleware import pageview_decorator\n\nROUTE_INDEX = \"core:index\"\nROUTE_ELIGIBILITY = \"eligibility:index\"\nROUTE_HELP = \"core:help\"\nROUTE_LOGGED_OUT = \"core:logged_out\"\n\nTEMPLATE_INDEX = \"core/index.html\"\nTEMPLATE_AGENCY = \"core/agency_index.html\"\nTEMPLATE_HELP = \"core/help.html\"\nTEMPLATE_LOGGED_OUT = \"core/logged_out.html\"\n\n\n@pageview_decorator\ndef index(request):\n    \"\"\"View handler for the main entry page.\"\"\"\n    session.reset(request)\n\n    page = viewmodels.Page(\n        title=_(\"core.pages.index.title\"),\n        headline=_(\"core.pages.index.headline\"),\n        modal=viewmodels.AgencySelector(\n            id=\"agency-selector\",\n            aria_labelledby_id=\"agency-selector-modal-label\",\n            button_text=_(\"core.pages.index.button\"),\n        ),\n    )\n\n    return TemplateResponse(request, TEMPLATE_INDEX, page.context_dict())\n\n\n@pageview_decorator\ndef agency_index(request, agency):\n    \"\"\"View handler for an agency entry page.\"\"\"\n    session.reset(request)\n    session.update(request, agency=agency, origin=agency.index_url)\n\n    button = viewmodels.Button.primary(text=_(\"core.pages.index.continue\"), url=reverse(ROUTE_ELIGIBILITY))\n\n    page = viewmodels.Page(\n        title=_(\"core.pages.agency_index.title\"),\n        headline=_(\"core.pages.agency_index.headline%(transit_agency_short_name)s\")\n        % {\"transit_agency_short_name\": agency.short_name},\n        button=button,\n    )\n\n    return TemplateResponse(request, TEMPLATE_AGENCY, page.context_dict())\n\n\n@pageview_decorator\ndef agency_public_key(request, agency):\n    \"\"\"View handler returns an agency's public key as plain text.\"\"\"\n    return HttpResponse(agency.public_key_data, content_type=\"text/plain\")\n\n\n@pageview_decorator\ndef help(request):\n    \"\"\"View handler for the help page.\"\"\"\n    if session.active_agency(request):\n        agency = session.agency(request)\n        buttons = viewmodels.Button.agency_contact_links(agency)\n    else:\n        buttons = [btn for a in models.TransitAgency.all_active() for btn in viewmodels.Button.agency_contact_links(a)]\n\n    buttons.append(viewmodels.Button.home(request, _(\"core.buttons.back\")))\n\n    page = viewmodels.Page(\n        title=_(\"core.buttons.help\"),\n        headline=_(\"core.buttons.help\"),\n        buttons=buttons,\n    )\n\n    return TemplateResponse(request, TEMPLATE_HELP, page.context_dict())\n\n\n@pageview_decorator\ndef bad_request(request, exception, template_name=\"400.html\"):\n    \"\"\"View handler for HTTP 400 Bad Request responses.\"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    page = viewmodels.ErrorPage.server_error(button=home)\n    t = loader.get_template(template_name)\n\n    return HttpResponseBadRequest(t.render(page.context_dict()))\n\n\n@pageview_decorator\ndef csrf_failure(request, reason):\n    \"\"\"\n    View handler for CSRF_FAILURE_VIEW with custom data.\n    \"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    page = viewmodels.ErrorPage.not_found(button=home, path=request.path)\n    t = loader.get_template(\"400.html\")\n\n    return HttpResponseNotFound(t.render(page.context_dict()))\n\n\n@pageview_decorator\ndef page_not_found(request, exception, template_name=\"404.html\"):\n    \"\"\"View handler for HTTP 404 Not Found responses.\"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    # show a more user-friendly message instead of not_found\n    page = viewmodels.ErrorPage.user_error(button=home, path=request.path)\n    t = loader.get_template(template_name)\n\n    return HttpResponseNotFound(t.render(page.context_dict()))\n\n\n@pageview_decorator\ndef server_error(request, template_name=\"500.html\"):\n    \"\"\"View handler for HTTP 500 Server Error responses.\"\"\"\n    if session.active_agency(request):\n        session.update(request, origin=session.agency(request).index_url)\n    else:\n        session.update(request, origin=reverse(ROUTE_INDEX))\n\n    home = viewmodels.Button.home(request)\n    page = viewmodels.ErrorPage.server_error(button=home)\n    t = loader.get_template(template_name)\n\n    return HttpResponseServerError(t.render(page.context_dict()))\n\n\ndef logged_out(request):\n    \"\"\"View handler for the final log out confirmation message.\"\"\"\n    page = viewmodels.Page(\n        title=_(\"core.pages.logged_out.title\"),\n        icon=viewmodels.Icon(\"happybus\", pgettext(\"image alt text\", \"core.icons.happybus\")),\n    )\n\n    return TemplateResponse(request, TEMPLATE_LOGGED_OUT, page.context_dict())\n", "path": "benefits/core/views.py"}]}