Skip to content

Commit

Permalink
Refactor: agency card eligibility error (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran authored May 1, 2024
2 parents b2c5642 + 6ad6894 commit 1262a4d
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2024-04-24 21:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0007_eligibilitytype_enrollment_index_template"),
]

operations = [
migrations.AddField(
model_name="eligibilityverifier",
name="unverified_template",
field=models.TextField(default="eligibility/unverified.html"),
),
]
2 changes: 2 additions & 0 deletions benefits/core/migrations/local_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"selection_label_template": "eligibility/includes/selection-label--mst-courtesy-card.html",
"start_template": "eligibility/start--mst-courtesy-card.html",
"form_class": "benefits.eligibility.forms.MSTCourtesyCard",
"unverified_template": "eligibility/unverified--mst-courtesy-card.html",
"help_template": "core/includes/help--mst-courtesy-card.html"
}
},
Expand Down Expand Up @@ -251,6 +252,7 @@
"selection_label_template": "eligibility/includes/selection-label--sbmtd-mobility-pass.html",
"start_template": "eligibility/start--sbmtd-mobility-pass.html",
"form_class": "benefits.eligibility.forms.SBMTDMobilityPass",
"unverified_template": "eligibility/unverified--sbmtd-mobility-pass.html",
"help_template": "core/includes/help--sbmtd-mobility-pass.html"
}
},
Expand Down
1 change: 1 addition & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class EligibilityVerifier(models.Model):
start_template = models.TextField(null=True, blank=True)
# reference to a form class used by this Verifier, e.g. benefits.app.forms.FormClass
form_class = models.TextField(null=True, blank=True)
unverified_template = models.TextField(default="eligibility/unverified.html")
help_template = models.TextField(null=True, blank=True)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "eligibility/unverified.html" %}
{% load i18n %}

{% block unverified-headline %}
{% translate "Your card information may not have been entered correctly." %}
{% endblock unverified-headline %}

{% block unverified-body %}
{% translate "The number and last name must be entered exactly as they appear on your MST Courtesy Card. Please check your card and try again, or contact your transit agency for help." %}
{% endblock unverified-body %}

{% block unverified-call-to-action %}
{% translate "Try again" as button_text %}
<div class="col-lg-3 col-8">{% include "core/includes/button--origin.html" with button_text=button_text %}</div>
{% endblock unverified-call-to-action %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "eligibility/unverified.html" %}
{% load i18n %}

{% block unverified-headline %}
{% translate "Your card information may not have been entered correctly." %}
{% endblock unverified-headline %}

{% block unverified-body %}
{% translate "The number and last name must be entered exactly as they appear on your SBMTD Reduced Fare Mobility ID card. Please check your card and try again, or contact your transit agency for help." %}
{% endblock unverified-body %}

{% block unverified-call-to-action %}
{% translate "Try again" as button_text %}
<div class="col-lg-3 col-8">{% include "core/includes/button--origin.html" with button_text=button_text %}</div>
{% endblock unverified-call-to-action %}
18 changes: 11 additions & 7 deletions benefits/eligibility/templates/eligibility/unverified.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@

<div class="container">
<h1 class="h2 text-center">
<span class="icon d-block pb-5">
{% include "core/includes/icon.html" with name="idcardquestion" %}
</span>
{% translate "Your eligibility could not be verified." %}
<span class="icon d-block pb-4">{% include "core/includes/icon.html" with name="idcardquestion" %}</span>
{% block unverified-headline %}
{% translate "Your eligibility could not be verified." %}
{% endblock unverified-headline %}
</h1>

<div class="row justify-content-center">
<div class="col-lg-8 pt-4">
<p>
{% translate "That’s okay! You may still be eligible for our program." %}
{% blocktranslate with short_name=agency.short_name %}Please reach out to {{ short_name }} for assistance.{% endblocktranslate %}
{% block unverified-body %}
{% translate "That’s okay! You may still be eligible for our program." %}
{% blocktranslate with short_name=agency.short_name %}Please reach out to {{ short_name }} for assistance.{% endblocktranslate %}
{% endblock unverified-body %}
</p>
</div>
</div>
Expand All @@ -32,7 +34,9 @@ <h1 class="h2 text-center">
</div>

<div class="row pt-8 justify-content-center">
<div class="col-lg-3 col-8">{% include "core/includes/button--index.html" %}</div>
{% block unverified-call-to-action %}
<div class="col-lg-3 col-8">{% include "core/includes/button--index.html" %}</div>
{% endblock unverified-call-to-action %}
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions benefits/eligibility/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

TEMPLATE_START = "eligibility/start.html"
TEMPLATE_CONFIRM = "eligibility/confirm.html"
TEMPLATE_UNVERIFIED = "eligibility/unverified.html"


@decorator_from_middleware(RecaptchaEnabled)
Expand Down Expand Up @@ -119,6 +118,7 @@ def confirm(request):

# GET from an unverified user, present the form
if request.method == "GET":
session.update(request, origin=reverse(ROUTE_CONFIRM))
return TemplateResponse(request, TEMPLATE_CONFIRM, context)
# POST form submission, process form data, make Eligibility Verification API call
elif request.method == "POST":
Expand Down Expand Up @@ -171,4 +171,4 @@ def unverified(request):

analytics.returned_fail(request, types_to_verify)

return TemplateResponse(request, TEMPLATE_UNVERIFIED)
return TemplateResponse(request, verifier.unverified_template)
23 changes: 19 additions & 4 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: 2024-04-26 16:57+0000\n"
"POT-Creation-Date: 2024-04-25 13:54-0700\n"
"Language: English\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -533,6 +533,24 @@ msgstr ""
msgid "You will need a few items to continue:"
msgstr ""

msgid "Your card information may not have been entered correctly."
msgstr ""

msgid ""
"The number and last name must be entered exactly as they appear on your MST "
"Courtesy Card. Please check your card and try again, or contact your transit "
"agency for help."
msgstr ""

msgid "Try again"
msgstr ""

msgid ""
"The number and last name must be entered exactly as they appear on your "
"SBMTD Reduced Fare Mobility ID card. Please check your card and try again, "
"or contact your transit agency for help."
msgstr ""

msgid "Unable to confirm eligibility"
msgstr ""

Expand Down Expand Up @@ -608,9 +626,6 @@ msgid ""
"agency for help."
msgstr ""

msgid "Try again"
msgstr ""

msgid ""
"You were not charged anything today. When boarding an MST fixed route bus, "
"tap this card when you board and you will be charged a reduced fare. You "
Expand Down
23 changes: 19 additions & 4 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: 2024-04-26 16:57+0000\n"
"POT-Creation-Date: 2024-04-25 13:54-0700\n"
"Language: Español\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -643,6 +643,24 @@ msgstr "Ha seleccionado un beneficio de tránsito para veteranos."
msgid "You will need a few items to continue:"
msgstr "Necesitará algunos artículos para continuar:"

msgid "Your card information may not have been entered correctly."
msgstr ""

msgid ""
"The number and last name must be entered exactly as they appear on your MST "
"Courtesy Card. Please check your card and try again, or contact your transit "
"agency for help."
msgstr ""

msgid "Try again"
msgstr "Intentar otra vez"

msgid ""
"The number and last name must be entered exactly as they appear on your "
"SBMTD Reduced Fare Mobility ID card. Please check your card and try again, "
"or contact your transit agency for help."
msgstr ""

msgid "Unable to confirm eligibility"
msgstr "No se pudo confirmar la elegibilidad"

Expand Down Expand Up @@ -724,9 +742,6 @@ msgid ""
"agency for help."
msgstr ""

msgid "Try again"
msgstr "Intentar otra vez"

msgid ""
"You were not charged anything today. When boarding an MST fixed route bus, "
"tap this card when you board and you will be charged a reduced fare. You "
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/specs/courtesy-cards.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Courtesy Cards", () => {
cy.get("#name").type(users.ineligible.name);
cy.get("#form-eligibility-verification button[type='submit']").click();

cy.contains("could not be verified");
cy.contains("may not have been entered correctly");
});

it("Validates an empty name field", () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/pytest/eligibility/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ROUTE_ENROLLMENT,
ROUTE_UNVERIFIED,
TEMPLATE_CONFIRM,
TEMPLATE_UNVERIFIED,
)

import benefits.eligibility.views
Expand Down Expand Up @@ -343,4 +342,4 @@ def test_unverified(client, mocked_analytics_module):

mocked_analytics_module.returned_fail.assert_called_once()
assert response.status_code == 200
assert response.template_name == TEMPLATE_UNVERIFIED
assert response.template_name == "eligibility/unverified.html"

0 comments on commit 1262a4d

Please sign in to comment.