From 66d7bca66760063b39b3575a192ccfdd9782b17e Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 9 Jul 2024 17:35:47 +0000 Subject: [PATCH 1/3] feat(cst): agency card form class --- benefits/eligibility/forms.py | 29 ++++++++++++++++++++++++ benefits/locale/en/LC_MESSAGES/django.po | 14 +++++++++--- benefits/locale/es/LC_MESSAGES/django.po | 22 +++++++++++++----- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py index d66ee506b..d239f213b 100644 --- a/benefits/eligibility/forms.py +++ b/benefits/eligibility/forms.py @@ -141,6 +141,35 @@ def clean(self): raise forms.ValidationError("reCAPTCHA failed") +class CSTAgencyCard(EligibilityVerificationForm): + """EligibilityVerification form for the CST Agency Card.""" + + def __init__(self, *args, **kwargs): + super().__init__( + title=_("Agency card information"), + headline=_("Let’s find the record of your transit benefit."), + blurb=_( + "We use the information on your CST Agency Card to find the record of your transit benefit in our system." + ), + name_label=_("Last Name"), + name_placeholder="Hernandez-Demarcos", + name_help_text=_( + "Please enter your last name the same way it is printed on your card, including capital letters and hyphens." + ), + sub_label=_("Agency Card number"), + sub_help_text=_("This is a 5-digit number on the front and back of your card."), + sub_placeholder="12345", + name_max_length=255, + sub_input_mode="numeric", + sub_max_length=5, + sub_pattern=r"\d{5}", + sub_custom_validity=_("Please enter a 5-digit number."), + name_custom_validity=_("Please enter your last name."), + *args, + **kwargs, + ) + + class MSTCourtesyCard(EligibilityVerificationForm): """EligibilityVerification form for the MST Courtesy Card.""" diff --git a/benefits/locale/en/LC_MESSAGES/django.po b/benefits/locale/en/LC_MESSAGES/django.po index 9a6d7d1cf..81eeeee2d 100644 --- a/benefits/locale/en/LC_MESSAGES/django.po +++ b/benefits/locale/en/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n" -"POT-Creation-Date: 2024-07-03 13:26-0700\n" +"POT-Creation-Date: 2024-07-09 10:43-0700\n" "Language: English\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -333,7 +333,7 @@ msgid "Let’s find the record of your transit benefit." msgstr "" msgid "" -"We use the information on your MST Courtesy Card to find the record of your " +"We use the information on your CST Agency Card to find the record of your " "transit benefit in our system." msgstr "" @@ -345,7 +345,7 @@ msgid "" "including capital letters and hyphens." msgstr "" -msgid "Courtesy Card number" +msgid "Agency Card number" msgstr "" msgid "This is a 5-digit number on the front and back of your card." @@ -357,6 +357,14 @@ msgstr "" msgid "Please enter your last name." msgstr "" +msgid "" +"We use the information on your MST Courtesy Card to find the record of your " +"transit benefit in our system." +msgstr "" + +msgid "Courtesy Card number" +msgstr "" + msgid "" "We use the information on your SBMTD Reduced Fare Mobility ID card to find " "the record of your transit benefit in our system." diff --git a/benefits/locale/es/LC_MESSAGES/django.po b/benefits/locale/es/LC_MESSAGES/django.po index 683f20c62..a19111839 100644 --- a/benefits/locale/es/LC_MESSAGES/django.po +++ b/benefits/locale/es/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n" -"POT-Creation-Date: 2024-07-03 13:26-0700\n" +"POT-Creation-Date: 2024-07-09 10:43-0700\n" "Language: Español\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -444,11 +444,11 @@ msgid "Let’s find the record of your transit benefit." msgstr "Veamos si podemos confirmar su elegibilidad." msgid "" -"We use the information on your MST Courtesy Card to find the record of your " +"We use the information on your CST Agency Card to find the record of your " "transit benefit in our system." msgstr "" -"Usamos la información de su tarjeta de cortesía de MST para confirmar su " -"elegibilidad en nuestro sistema." +"Utilizamos la información de su Tarjeta de agencia CST para encontrar el " +"registro de su beneficio de tránsito en nuestro sistema." msgid "Last Name" msgstr "Apellido" @@ -460,8 +460,8 @@ msgstr "" "Ingrese su apellido de la misma manera que está impreso en su tarjeta, " "incluyendo mayúsculas y guiones." -msgid "Courtesy Card number" -msgstr "Número de tarjeta de cortesía de MST" +msgid "Agency Card number" +msgstr "Número de tarjeta de agencia de CST" msgid "This is a 5-digit number on the front and back of your card." msgstr "Este es un número de 5 dígitos en el anverso y reverso de su tarjeta." @@ -472,6 +472,16 @@ msgstr "Ingrese un número de 5 dígitos." msgid "Please enter your last name." msgstr "Ingrese su apellido." +msgid "" +"We use the information on your MST Courtesy Card to find the record of your " +"transit benefit in our system." +msgstr "" +"Usamos la información de su tarjeta de cortesía de MST para confirmar su " +"elegibilidad en nuestro sistema." + +msgid "Courtesy Card number" +msgstr "Número de tarjeta de cortesía de MST" + msgid "" "We use the information on your SBMTD Reduced Fare Mobility ID card to find " "the record of your transit benefit in our system." From 4a74929a1780b7efc612a956e85befe96d05be34 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 9 Jul 2024 17:45:44 +0000 Subject: [PATCH 2/3] fix(cst): update enrollment success translation --- benefits/locale/en/LC_MESSAGES/django.po | 2 +- benefits/locale/es/LC_MESSAGES/django.po | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/benefits/locale/en/LC_MESSAGES/django.po b/benefits/locale/en/LC_MESSAGES/django.po index 81eeeee2d..c07625ed3 100644 --- a/benefits/locale/en/LC_MESSAGES/django.po +++ b/benefits/locale/en/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n" -"POT-Creation-Date: 2024-07-09 10:43-0700\n" +"POT-Creation-Date: 2024-07-09 10:45-0700\n" "Language: English\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/benefits/locale/es/LC_MESSAGES/django.po b/benefits/locale/es/LC_MESSAGES/django.po index a19111839..3f01929cb 100644 --- a/benefits/locale/es/LC_MESSAGES/django.po +++ b/benefits/locale/es/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n" -"POT-Creation-Date: 2024-07-09 10:43-0700\n" +"POT-Creation-Date: 2024-07-09 10:45-0700\n" "Language: Español\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -890,15 +890,16 @@ msgid "" "fare. You will need to re-enroll if you choose to change the card you use to " "pay for transit service." msgstr "" -"Su tarjeta sin contacto ahora está inscrita en el beneficio de tránsito de " -"la tarjeta de agencia de CST. Cuando suba a un autobús de CST, toque el " -"lector con esta tarjeta y se le cobrará una tarifa reducida. Deberá volver a " +"Su tarjeta sin contacto ahora está inscrita en un beneficio de tránsito de " +"Tarjeta de agencia de CST. Cuando suba a un autobús de CST, toque el lector " +"con esta tarjeta y se le cobrará una tarifa reducida. Deberá volver a " "inscribirse si elige cambiar la tarjeta que usa para pagar el servicio de " "tránsito." msgid "" "You were not charged anything today. Thank you for using Cal-ITP Benefits!" -msgstr "No se le cobró nada hoy. ¡Gracias por usar Cal-ITP Benefits!" +msgstr "" +"No se le cobrará nada hoy. ¡Gracias por utilizar los beneficios de Cal-ITP!" msgid "" "You were not charged anything today. When boarding a CST bus, tap your " From a65463d177a356f8b728ce1b207b30f74d718c4c Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Wed, 10 Jul 2024 18:07:38 +0000 Subject: [PATCH 3/3] test(cst): cover the new eligibilty form --- tests/pytest/eligibility/test_forms.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/pytest/eligibility/test_forms.py b/tests/pytest/eligibility/test_forms.py index 42799ebac..1460bc9e9 100644 --- a/tests/pytest/eligibility/test_forms.py +++ b/tests/pytest/eligibility/test_forms.py @@ -1,4 +1,22 @@ -from benefits.eligibility.forms import MSTCourtesyCard, SBMTDMobilityPass +from benefits.eligibility.forms import CSTAgencyCard, MSTCourtesyCard, SBMTDMobilityPass + + +def test_CSTAgencyCard(): + form = CSTAgencyCard(data={"sub": "12345", "name": "Gonzalez"}) + + assert form.is_valid() + + sub_attrs = form.fields["sub"].widget.attrs + assert sub_attrs["pattern"] == r"\d{5}" + assert sub_attrs["inputmode"] == "numeric" + assert sub_attrs["maxlength"] == 5 + assert sub_attrs["data-custom-validity"] == "Please enter a 5-digit number." + + name_attrs = form.fields["name"].widget.attrs + assert name_attrs["maxlength"] == 255 + assert name_attrs["data-custom-validity"] == "Please enter your last name." + + assert form.use_custom_validity def test_MSTCourtesyCard():