Skip to content

Commit

Permalink
feat(enrollment): agencies have their own success template
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Aug 7, 2023
1 parent 0998a99 commit ffbe306
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 12 deletions.
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.2.3 on 2023-07-26 21:42
# Generated by Django 4.2.4 on 2023-08-07 16:23

from django.db import migrations, models
import django.db.models.deletion
Expand Down Expand Up @@ -110,6 +110,7 @@ class Migration(migrations.Migration):
("jws_signing_alg", models.TextField()),
("index_template", models.TextField()),
("eligibility_index_template", models.TextField()),
("enrollment_success_template", models.TextField()),
("help_template", models.TextField(null=True)),
("eligibility_types", models.ManyToManyField(to="core.eligibilitytype")),
("eligibility_verifiers", models.ManyToManyField(to="core.eligibilityverifier")),
Expand Down
2 changes: 2 additions & 0 deletions benefits/core/migrations/0002_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def load_data(app, *args, **kwargs):
payment_processor=mst_payment_processor,
index_template="core/index--mst.html",
eligibility_index_template="eligibility/index--mst.html",
enrollment_success_template="enrollment/success--mst.html",
help_template="core/includes/help--mst.html",
)
mst_agency.eligibility_types.set([mst_senior_type, mst_veteran_type, mst_courtesy_card_type])
Expand All @@ -278,6 +279,7 @@ def load_data(app, *args, **kwargs):
payment_processor=sacrt_payment_processor,
index_template="core/index--sacrt.html",
eligibility_index_template="eligibility/index--sacrt.html",
enrollment_success_template="enrollment/success--sacrt.html",
)
sacrt_agency.eligibility_types.set([sacrt_senior_type])
sacrt_agency.eligibility_verifiers.set([sacrt_oauth_claims_verifier])
Expand Down
1 change: 1 addition & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class TransitAgency(models.Model):
jws_signing_alg = models.TextField()
index_template = models.TextField()
eligibility_index_template = models.TextField()
enrollment_success_template = models.TextField()
help_template = models.TextField(null=True)

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

{% block success-message %}
{% translate "enrollment.pages.success.message.mst" %}
{% endblock success-message %}
6 changes: 6 additions & 0 deletions benefits/enrollment/templates/enrollment/success--sacrt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "enrollment/success.html" %}
{% load i18n %}

{% block success-message %}
{% translate "enrollment.pages.success.message.sacrt" %}
{% endblock success-message %}
5 changes: 4 additions & 1 deletion benefits/enrollment/templates/enrollment/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ <h1 class="pb-lg-5 pb-4">{% translate "enrollment.pages.success.headline" %}</h1
<div class="col-12 col-sm-12 col-lg-9">
<div class="row flex-column-reverse flex-lg-row">
<div class="col-12 col-lg-6">
<p class="pt-lg-4 mt-lg-3">{% translate "enrollment.pages.success.confirm_item.details" %}</p>
<p class="pt-lg-4 mt-lg-3">
{% block success-message %}
{% endblock success-message %}
</p>
<p class="pt-4">{% translate "enrollment.pages.success.thankyou" %}</p>
</div>
<div class="col-12 offset-lg-1 col-lg-5">
Expand Down
9 changes: 7 additions & 2 deletions benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from django.utils.decorators import decorator_from_middleware

from benefits.core import models, session
from benefits.core.middleware import EligibleSessionRequired, VerifierSessionRequired, pageview_decorator
from benefits.core.middleware import (
EligibleSessionRequired,
VerifierSessionRequired,
pageview_decorator,
)
from benefits.core.views import ROUTE_LOGGED_OUT
from . import analytics, api, forms

Expand Down Expand Up @@ -111,11 +115,12 @@ def success(request):
request.path = "/enrollment/success"
session.update(request, origin=reverse(ROUTE_SUCCESS))

agency = session.agency(request)
verifier = session.verifier(request)

if session.logged_in(request) and verifier.auth_provider.supports_sign_out:
# overwrite origin for a logged in user
# if they click the logout button, they are taken to the new route
session.update(request, origin=reverse(ROUTE_LOGGED_OUT))

return TemplateResponse(request, TEMPLATE_SUCCESS)
return TemplateResponse(request, agency.enrollment_success_template)
15 changes: 10 additions & 5 deletions benefits/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,17 @@ msgstr "Success"
msgid "enrollment.pages.success.headline"
msgstr "Success! Your transit benefit is now connected to your card."

msgid "enrollment.pages.success.confirm_item.details"
msgid "enrollment.pages.success.message.mst"
msgstr ""
"You were not charged anything today. When boarding a [short-name] "
"[transportaton-type], [card-functionality] and you will be charged a reduced "
"fare. You will need to re-enroll if you choose to change the card you use to "
"pay for transit service."
"You were not charged anything today. When boarding an MST fixed route bus, "
"tap this card when you get on the bus and you will be charged a reduced fare. "
"You will need to re-enroll if you choose to change the card you use to pay for transit service."

msgid "enrollment.pages.success.message.sacrt"
msgstr ""
"You were not charged anything today. When boarding SacRT light rail, "
"tap this card when you get on and you will be charged a reduced fare. "
"You will need to re-enroll if you choose to change the card you use to pay for transit service."

msgid "enrollment.pages.success.thankyou"
msgstr "Thank you for using Cal-ITP Benefits!"
Expand Down
1 change: 1 addition & 0 deletions tests/pytest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def model_TransitAgency(model_PemData, model_EligibilityType, model_EligibilityV
jws_signing_alg="alg",
index_template="core/agency-index.html",
eligibility_index_template="eligibility/index.html",
enrollment_success_template="enrollment/success.html",
)

# add many-to-many relationships after creation, need ID on both sides
Expand Down
8 changes: 5 additions & 3 deletions tests/pytest/enrollment/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ def test_success_no_verifier(client):

@pytest.mark.django_db
@pytest.mark.usefixtures("mocked_session_verifier_auth_required")
def test_success_authentication_logged_in(mocker, client):
def test_success_authentication_logged_in(mocker, client, model_TransitAgency):
mock_session = mocker.patch("benefits.enrollment.views.session")
mock_session.logged_in.return_value = True
mock_session.agency.return_value = model_TransitAgency

path = reverse(ROUTE_SUCCESS)
response = client.get(path)
Expand All @@ -214,9 +215,10 @@ def test_success_authentication_logged_in(mocker, client):

@pytest.mark.django_db
@pytest.mark.usefixtures("mocked_session_verifier_auth_required")
def test_success_authentication_not_logged_in(mocker, client):
def test_success_authentication_not_logged_in(mocker, client, model_TransitAgency):
mock_session = mocker.patch("benefits.enrollment.views.session")
mock_session.logged_in.return_value = False
mock_session.agency.return_value = model_TransitAgency

path = reverse(ROUTE_SUCCESS)
response = client.get(path)
Expand All @@ -226,7 +228,7 @@ def test_success_authentication_not_logged_in(mocker, client):


@pytest.mark.django_db
@pytest.mark.usefixtures("mocked_session_verifier_auth_not_required")
@pytest.mark.usefixtures("mocked_session_agency", "mocked_session_verifier_auth_not_required")
def test_success_no_authentication(client):
path = reverse(ROUTE_SUCCESS)
response = client.get(path)
Expand Down

0 comments on commit ffbe306

Please sign in to comment.