Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: parameterize messages with agency-specific content #1196

Merged
merged 5 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion benefits/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.5 on 2023-01-10 19:53
# Generated by Django 4.1.5 on 2023-01-11 23:23

from django.db import migrations, models
import django.db.models.deletion
Expand Down Expand Up @@ -120,6 +120,7 @@ class Migration(migrations.Migration):
("phone", models.TextField()),
("active", models.BooleanField(default=False)),
("jws_signing_alg", models.TextField()),
("eligibility_index_intro", models.TextField()),
("eligibility_types", models.ManyToManyField(to="core.eligibilitytype")),
("eligibility_verifiers", models.ManyToManyField(to="core.eligibilityverifier")),
(
Expand Down
5 changes: 4 additions & 1 deletion benefits/core/migrations/0002_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def load_sample_data(app, *args, **kwargs):
unverified_title=_("eligibility.pages.unverified.login_gov.title"),
unverified_blurb=_("eligibility.pages.unverified.login_gov.p[0]"),
eligibility_confirmed_item_heading=_("enrollment.pages.index.login_gov.eligibility_confirmed_item.heading"),
eligibility_confirmed_item_details=_("enrollment.pages.index.mst_login.eligibility_confirmed_item.details"),
eligibility_confirmed_item_details=_(
"enrollment.pages.index.login_gov.eligibility_confirmed_item.details%(transit_agency_short_name)s"
),
enrollment_success_confirm_item_details=_("enrollment.pages.success.login_gov.confirm_item.details"),
enrollment_success_expiry_item_heading=None,
enrollment_success_expiry_item_details=None,
Expand Down Expand Up @@ -188,6 +190,7 @@ def load_sample_data(app, *args, **kwargs):
public_key=client_public_key,
jws_signing_alg="RS256",
payment_processor=payment_processor,
eligibility_index_intro=_("eligibility.pages.index.p[0].mst"),
)
mst_agency.eligibility_types.set([senior_type, courtesy_card_type])
mst_agency.eligibility_verifiers.set([verifier1, verifier2])
Expand Down
1 change: 1 addition & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,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()

def __str__(self):
return self.long_name
Expand Down
7 changes: 4 additions & 3 deletions benefits/eligibility/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ def index(request):

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(
title=_("eligibility.pages.index.title"),
headline=_("eligibility.pages.index.headline"),
paragraphs=[
format_html(_("eligibility.pages.index.p[0]%(info_link)s") % {"info_link": f"{help_page}#what-is-cal-itp"})
],
paragraphs=[intro],
forms=forms.EligibilityVerifierSelectionForm(agency=agency),
)

Expand Down
6 changes: 5 additions & 1 deletion benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def index(request):

if verifier.eligibility_confirmed_item_heading or verifier.eligibility_confirmed_item_details:
heading = _(verifier.eligibility_confirmed_item_heading) if verifier.eligibility_confirmed_item_heading else None
details = _(verifier.eligibility_confirmed_item_details) if verifier.eligibility_confirmed_item_details else None
details = (
_(verifier.eligibility_confirmed_item_details) % {"transit_agency_short_name": agency.short_name}
thekaveman marked this conversation as resolved.
Show resolved Hide resolved
if verifier.eligibility_confirmed_item_details
else None
)
confirmed_eligibility_item = viewmodels.MediaItem(
icon=viewmodels.Icon("happybus", pgettext("image alt text", "core.icons.happybus")),
heading=heading,
Expand Down
33 changes: 20 additions & 13 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-01-10 19:57+0000\n"
"POT-Creation-Date: 2023-01-12 00:44+0000\n"
"Language: English\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -55,10 +55,14 @@ msgstr ""
msgid "enrollment.pages.index.login_gov.eligibility_confirmed_item.heading"
msgstr "Your eligibility is confirmed for an Older Adult benefit"

msgid "enrollment.pages.index.mst_login.eligibility_confirmed_item.details"
#, python-format
msgid ""
"enrollment.pages.index.login_gov.eligibility_confirmed_item.details"
"%(transit_agency_short_name)s"
msgstr ""
"Your eligibility has been verified by Login.gov. This benefit will give you "
"a half-price fare on public transportation with MST."
"a half-price fare on public transportation with "
"%(transit_agency_short_name)s."

msgid "enrollment.pages.success.login_gov.confirm_item.details"
msgstr ""
Expand Down Expand Up @@ -136,6 +140,11 @@ 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 "core.pages.agency_index.h2"
msgstr "Your benefit applies every time you tap to ride"

Expand Down Expand Up @@ -438,23 +447,21 @@ msgstr ""
"Questions about the items above? Please visit our <a href=\"%(help_link)s"
"\">Help Page</a>."

#, 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 "Select a benefit option"

msgid "eligibility.pages.index.headline"
msgstr ""
"Connect your bank card to your public transit discount with Cal-ITP Benefits."

#, python-format
msgid "eligibility.pages.index.p[0]%(info_link)s"
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. 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>"

#, python-format
msgid "eligibility.pages.index.help_text%(help_link)s"
msgstr ""
Expand Down
33 changes: 20 additions & 13 deletions benefits/locale/es/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-01-10 19:57+0000\n"
"POT-Creation-Date: 2023-01-12 00:44+0000\n"
"Language: Español\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -55,10 +55,14 @@ msgstr ""
msgid "enrollment.pages.index.login_gov.eligibility_confirmed_item.heading"
msgstr "Su eligibilidad es confirmada para un beneficio de Adulto Mayor"

msgid "enrollment.pages.index.mst_login.eligibility_confirmed_item.details"
#, python-format
msgid ""
"enrollment.pages.index.login_gov.eligibility_confirmed_item.details"
"%(transit_agency_short_name)s"
msgstr ""
"Su elegibilidad ha sido verificada por Login.gov. Este beneficio le dará una "
"tarifa a mitad de precio en el transporte público con MST."
"tarifa a mitad de precio en el transporte público con "
"%(transit_agency_short_name)s."

msgid "enrollment.pages.success.login_gov.confirm_item.details"
msgstr ""
Expand Down Expand Up @@ -143,6 +147,11 @@ msgstr ""
"volver a presenter una solicitud si elige cambiar la tarjeta bancaria que "
"usa para pagar el servicio de tránsito."

msgid "eligibility.pages.index.p[0].mst"
msgstr ""
"Puede acercar su tarjeta de crédito o débito cuando aborde un autobús de MST "
"y su tarifa con descuento se aplicará automáticamente cada vez que viaje. "

msgid "core.pages.agency_index.h2"
msgstr "Su beneficio se aplicará cada vez que acerque su tarjeta para viajar"

Expand Down Expand Up @@ -453,24 +462,22 @@ msgstr ""
"¿Preguntas sobre los artículos anteriores? Visite nuestro <a href="
"\"%(help_link)s\">Página de Ayuda</a>."

msgid "eligibility.pages.index.title"
msgstr "Seleccione una opción de beneficio"

msgid "eligibility.pages.index.headline"
msgstr ""
"Conecté su tarjeta bancaria a su descuento de transporte público con los "
"Beneficios de Cal-ITP"

#, python-format
msgid "eligibility.pages.index.p[0]%(info_link)s"
msgstr ""
"Puede acercar su tarjeta de crédito o débito cuando aborde un autobús de MST "
"y su tarifa con descuento se aplicará automáticamente cada vez que viaje. "
"Cal-ITP no guarda su información y no necesita crear una cuenta. Verifique "
"para obtener su beneficio y conecte su tarjeta bancaria hoy. <strong><a "
"class='info-link' href=\"%(info_link)s\">Obtenga más información sobre los "
"Beneficios de Cal-ITP</a></strong><span class='period'>.</span>"

msgid "eligibility.pages.index.title"
msgstr "Seleccione una opción de beneficio"

msgid "eligibility.pages.index.headline"
msgstr ""
"Conecté su tarjeta bancaria a su descuento de transporte público con los "
"Beneficios de Cal-ITP"

#, python-format
msgid "eligibility.pages.index.help_text%(help_link)s"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions tests/pytest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def model_TransitAgency(model_PemData, model_EligibilityType, model_EligibilityV
private_key=model_PemData,
public_key=model_PemData,
jws_signing_alg="alg",
eligibility_index_intro="",
)

# add many-to-many relationships after creation, need ID on both sides
Expand Down