Skip to content

Commit

Permalink
refactor(eligibility/index): intro content
Browse files Browse the repository at this point in the history
use a template per agency to define customized content
  • Loading branch information
thekaveman committed Jul 11, 2023
1 parent 161a103 commit 51b9b13
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 127 deletions.
4 changes: 2 additions & 2 deletions benefits/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.3 on 2023-07-08 02:54
# Generated by Django 4.2.3 on 2023-07-11 17:22

from django.db import migrations, models
import django.db.models.deletion
Expand Down Expand Up @@ -112,7 +112,7 @@ class Migration(migrations.Migration):
("phone", models.TextField()),
("active", models.BooleanField(default=False)),
("jws_signing_alg", models.TextField()),
("eligibility_index_intro", models.TextField()),
("eligibility_index_template", models.TextField()),
("transit_type", models.TextField()),
("eligibility_types", models.ManyToManyField(to="core.eligibilitytype")),
("eligibility_verifiers", models.ManyToManyField(to="core.eligibilityverifier")),
Expand Down
4 changes: 2 additions & 2 deletions benefits/core/migrations/0002_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def load_data(app, *args, **kwargs):
public_key=client_public_key,
jws_signing_alg=os.environ.get("MST_AGENCY_JWS_SIGNING_ALG", "RS256"),
payment_processor=mst_payment_processor,
eligibility_index_intro=_("eligibility.pages.index.p[0].mst"),
eligibility_index_template="eligibility/index--mst.html",
transit_type=_("agency.variables.mst.transit_type"),
)
mst_agency.eligibility_types.set([mst_senior_type, mst_veteran_type, mst_courtesy_card_type])
Expand All @@ -294,7 +294,7 @@ def load_data(app, *args, **kwargs):
public_key=client_public_key,
jws_signing_alg=os.environ.get("SACRT_AGENCY_JWS_SIGNING_ALG", "RS256"),
payment_processor=sacrt_payment_processor,
eligibility_index_intro=_("eligibility.pages.index.p[0].sacrt"),
eligibility_index_template="eligibility/index--sacrt.html",
transit_type=_("agency.variables.sacrt.transit_type"),
)
sacrt_agency.eligibility_types.set([sacrt_senior_type])
Expand Down
2 changes: 1 addition & 1 deletion benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class TransitAgency(models.Model):
public_key = models.ForeignKey(PemData, related_name="+", on_delete=models.PROTECT)
# The JWS-compatible signing algorithm
jws_signing_alg = models.TextField()
eligibility_index_intro = models.TextField()
eligibility_index_template = models.TextField()
transit_type = models.TextField()

def __str__(self):
Expand Down
7 changes: 7 additions & 0 deletions benefits/eligibility/templates/eligibility/index--mst.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "eligibility/index.html" %}

{% load i18n %}

{% block explanatory-text %}
<p class="pt-4 pb-4 pb-lg-8">{% translate "eligibility.pages.index.intro.mst" %}</p>
{% endblock explanatory-text %}
7 changes: 7 additions & 0 deletions benefits/eligibility/templates/eligibility/index--sacrt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "eligibility/index.html" %}

{% load i18n %}

{% block explanatory-text %}
<p class="pt-4 pb-4 pb-lg-8">{% translate "eligibility.pages.index.intro.sacrt" %}</p>
{% endblock explanatory-text %}
21 changes: 3 additions & 18 deletions benefits/eligibility/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.decorators import decorator_from_middleware
from django.utils.html import format_html
from django.utils.translation import pgettext, gettext as _

from benefits.core import recaptcha, session, viewmodels
from benefits.core.middleware import AgencySessionRequired, LoginRequired, RecaptchaEnabled, VerifierSessionRequired
from benefits.core.models import EligibilityVerifier
from benefits.core.views import ROUTE_HELP
from . import analytics, forms, verify


Expand All @@ -24,7 +22,6 @@
ROUTE_UNVERIFIED = "eligibility:unverified"
ROUTE_ENROLLMENT = "enrollment:index"

TEMPLATE_INDEX = "eligibility/index.html"
TEMPLATE_START = "eligibility/start.html"
TEMPLATE_CONFIRM = "eligibility/confirm.html"
TEMPLATE_UNVERIFIED = "eligibility/unverified.html"
Expand All @@ -50,20 +47,7 @@ def index(request, agency=None):
# this may or may not require OAuth, with a different set of scope/claims than what is already stored
session.logout(request)

eligibility_start = reverse(ROUTE_START)

help_page = reverse(ROUTE_HELP)

agency_intro = _(agency.eligibility_index_intro) if isinstance(agency.eligibility_index_intro, str) else ""
common_intro = _("eligibility.pages.index.p[0]%(info_link)s") % {"info_link": f"{help_page}#what-is-cal-itp"}
intro = format_html(agency_intro + common_intro)
page = viewmodels.Page(
paragraphs=[intro],
)

context = {"form": forms.EligibilityVerifierSelectionForm(agency=agency)}
context["help_page"] = help_page
context["help_text"] = format_html(_("eligibility.pages.index.help_text%(help_link)s") % {"help_link": help_page})

if request.method == "POST":
form = forms.EligibilityVerifierSelectionForm(data=request.POST, agency=agency)
Expand All @@ -76,15 +60,16 @@ def index(request, agency=None):
types_to_verify = agency.type_names_to_verify(verifier)
analytics.selected_verifier(request, types_to_verify)

eligibility_start = reverse(ROUTE_START)
response = redirect(eligibility_start)
else:
# form was not valid, allow for correction/resubmission
if recaptcha.has_error(form):
messages.error(request, "Recaptcha failed. Please try again.")
context["form"] = form
response = TemplateResponse(request, TEMPLATE_INDEX, context)
response = TemplateResponse(request, agency.eligibility_index_template, context)
else:
response = TemplateResponse(request, TEMPLATE_INDEX, context)
response = TemplateResponse(request, agency.eligibility_index_template, context)

return response

Expand Down
81 changes: 32 additions & 49 deletions benefits/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n"
"POT-Creation-Date: 2023-07-10 22:55+0000\n"
"POT-Creation-Date: 2023-07-11 17:41+0000\n"
"Language: English\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -83,20 +83,9 @@ msgstr ""
"contactless payment cards. You will also need to reapply if you choose to "
"change the bank card you use to pay for transit service."

msgid "eligibility.pages.index.p[0].mst"
msgstr ""
"You can tap your credit or debit card when you board an MST bus, and your "
"discounted fare will automatically apply every time you ride. "

msgid "agency.variables.mst.transit_type"
msgstr "bus"

msgid "eligibility.pages.index.p[0].sacrt"
msgstr ""
"You can tap your credit or debit card when you board SacRT public "
"transportation, and your discounted fare will automatically apply every time "
"you ride. "

msgid "agency.variables.sacrt.transit_type"
msgstr "light rail"

Expand Down Expand Up @@ -274,16 +263,16 @@ msgstr ""
msgid "core.pages.help.foss.link"
msgstr "GitHub"

msgid "core.buttons.previous_page"
msgstr "Previous Page"

msgid "core.pages.index.agency_selector.headline"
msgstr "Please choose your transit provider:"

#, python-format
msgid "core.pages.index.agency_selector%(agency_short_name)s"
msgstr "%(agency_short_name)s logo"

msgid "core.buttons.previous_page"
msgstr "Previous Page"

msgid "core.includes.nocookies.brand"
msgstr "Cookies are disabled"

Expand All @@ -304,13 +293,12 @@ msgstr ""
"JavaScript. Please enable JavaScript for this website and"

msgid "eligibility.pages.index.mst_courtesy_card.label"
msgstr "I have an MST Courtesy Card"
msgstr "MST Courtesy Card"

msgid "eligibility.pages.index.mst_courtesy_card.description"
msgstr ""
"This option is for people who have a current Courtesy Card or an MST RIDES "
"Eligibility card. This benefit may need to be renewed in the future. Using "
"this benefit means your new transit fare is half of the standard fare."
"This option is for people who have a current Courtesy Card [optional "
"qualifier]."

msgid "eligibility.pages.index.senior.label"
msgstr "Older Adult"
Expand All @@ -327,8 +315,11 @@ msgstr ""
"This option is for people who have served in the active military, naval, or "
"air service, and who were discharged or released therefrom under conditions "
"other than dishonorable. You will need to <a href='https://www.va.gov/"
"resources/verifying-your-identity-on-vagov/' target=\"_blank\" rel="
"\"noopener noreferrer\">verify your identity through VA.gov</a>"
"resources/verifying-your-identity-on-vagov/' target=\"_blank\" "
"rel=\"noopener noreferrer\">verify your identity through VA.gov</a>"

msgid "core.pages.index.button"
msgstr "Choose your Provider"

msgid "core.pages.landing.h2"
msgstr ""
Expand All @@ -341,7 +332,7 @@ msgid "core.pages.logged_out.headline[1]"
msgstr "Thank you for using Cal-ITP Benefits!"

msgid "eligibility.pages.index.label"
msgstr "Select the option that best applies to you:"
msgstr "Which transit benefit would you like to enroll in?"

msgid "core.pages.error.title"
msgstr "Error"
Expand Down Expand Up @@ -389,9 +380,6 @@ msgstr "Choose Provider"
msgid "core.pages.index.headline"
msgstr "Get reduced fare on public transportation when you tap to ride"

msgid "core.pages.index.button"
msgstr "Choose your Provider"

msgid "core.pages.index.continue"
msgstr "Get Started"

Expand Down Expand Up @@ -496,6 +484,22 @@ msgstr ""
"If you do not have an account with any of these services, you will need to "
"create one. We recommend using Login.gov."

msgid "eligibility.pages.index.intro.mst"
msgstr ""
"Cal-ITP doesn’t save any of your information. All MST transit benefits "
"[action] by [rate of discount] for [affected service] on [transit options]."

msgid "eligibility.pages.index.intro.sacrt"
msgstr ""
"Cal-ITP doesn’t save any of your information. All SacRT transit benefits "
"[action] by [rate of discount] for [affected service] on [transit options]."

msgid "eligibility.pages.index.title"
msgstr "Choose benefit option"

msgid "eligibility.pages.index.headline"
msgstr "Choose the transit benefit you would like to enroll in"

msgid "eligibility.pages.start.sub_headline"
msgstr "You will need a few items to connect your benefit:"

Expand Down Expand Up @@ -532,27 +536,6 @@ msgstr "You selected a Veteran transit benefit."
msgid "eligibility.buttons.veteran.signin"
msgstr "Continue to VA.gov"

#, python-format
msgid "eligibility.pages.index.p[0]%(info_link)s"
msgstr ""
"Cal-ITP doesn’t save any of your information, and you don’t need to create "
"an account. Verify to get your benefit, and connect your bank card today. "
"<strong><a class='info-link' href=\"%(info_link)s\">Learn more about Cal-ITP "
"Benefits.</a></strong>"

msgid "eligibility.pages.index.title"
msgstr "Choose benefit option"

msgid "eligibility.pages.index.headline"
msgstr ""
"Choose the transit benefit you would like to enroll in"

#, python-format
msgid "eligibility.pages.index.help_text%(help_link)s"
msgstr ""
"Not sure which option is right for you? Please visit our <a href="
"\"%(help_link)s\">Help Page</a>."

msgid "eligibility.pages.unverified.headline"
msgstr "Your eligibility could not be verified."

Expand All @@ -573,15 +556,15 @@ msgstr "We don’t store your information, and you won’t be charged."
msgid "enrollment.pages.index.link_card_item.p[1]s[0]"
msgstr "Please use a debit or credit card by Visa or Mastercard."

msgid "core.buttons.wait"
msgstr "Please wait..."

msgid "enrollment.pages.index.title"
msgstr "Connect your card"

msgid "enrollment.pages.index.headline"
msgstr "Your eligibility is confirmed! You’re nearly there."

msgid "core.buttons.wait"
msgstr "Please wait..."

msgid "enrollment.buttons.payment_partner"
msgstr "Connect your Card"

Expand Down

0 comments on commit 51b9b13

Please sign in to comment.