Skip to content

Commit

Permalink
Feat: CalFresh enrollment success with expiration (#1988)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman authored Apr 29, 2024
2 parents f21ec32 + 9cdacdc commit fecc1cc
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 7 deletions.
17 changes: 12 additions & 5 deletions benefits/enrollment/templates/enrollment/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@

{% block headline %}
<div class="col-lg-8">
<h1 class="pb-lg-5 pb-4">{% translate "Success! Your transit benefit is now connected to your card." %}</h1>
<h1 class="pb-lg-4 mb-lg-3 pb-4">{% translate "Success! Your transit benefit is now connected to your card." %}</h1>
</div>
{% endblock headline %}

{% block inner-content %}
<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-7">
<p class="pt-lg-4 mt-lg-3">
{% block success-message %}
{% endblock success-message %}
</p>
{# djlint:off #}
{% if enrollment.supports_expiration %}
<h2 class="h3 mt-lg-3 mb-1">{% translate "Your benefit will expire on" %} {{ enrollment.expires|date }}.</h2>
<p>
{% else %}
<p class="pt-lg-4 mt-lg-3">
{% endif %}
{% block success-message %}
{% endblock success-message %}
</p>
{# djlint:on #}
<p class="pt-4">{% translate "Thank you for using Cal-ITP Benefits!" %}</p>
</div>
<div class="col-12 col-lg-5">
Expand Down
Empty file added benefits/locale/__init__.py
Empty file.
5 changes: 4 additions & 1 deletion 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-25 14:33-0700\n"
"POT-Creation-Date: 2024-04-26 16:57+0000\n"
"Language: English\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -637,6 +637,9 @@ msgstr ""
msgid "Success! Your transit benefit is now connected to your card."
msgstr ""

msgid "Your benefit will expire on"
msgstr ""

msgid "Thank you for using Cal-ITP Benefits!"
msgstr ""

Expand Down
Empty file added benefits/locale/en/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions benefits/locale/en/formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#date-and-time-formatting-specifiers
DATE_FORMAT = "F j, Y"
5 changes: 4 additions & 1 deletion 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-25 14:33-0700\n"
"POT-Creation-Date: 2024-04-26 16:57+0000\n"
"Language: Español\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -763,6 +763,9 @@ msgstr "Éxito"
msgid "Success! Your transit benefit is now connected to your card."
msgstr "¡Éxito! Su beneficio de tránsito ahora está conectado a su tarjeta."

msgid "Your benefit will expire on"
msgstr ""

msgid "Thank you for using Cal-ITP Benefits!"
msgstr "¡Gracias por usar Cal-ITP Benefits!"

Expand Down
Empty file added benefits/locale/es/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions benefits/locale/es/formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Both “d” and “e” are backslash-escaped, because otherwise each is a format string
# that displays the day and the timezone name, respectively.
# Instead we want the literal word "de"
# https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#date-and-time-formatting-specifiers
DATE_FORMAT = r"j \d\e F \d\e Y"
5 changes: 5 additions & 0 deletions benefits/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ def RUNTIME_ENVIRONMENT():
TIME_ZONE = "UTC"
USE_TZ = True

# https://docs.djangoproject.com/en/5.0/topics/i18n/formatting/#creating-custom-format-files
FORMAT_MODULE_PATH = [
"benefits.locale",
]

# Static files (CSS, JavaScript, Images)

STATIC_URL = "/static/"
Expand Down
Empty file added tests/__init__.py
Empty file.
Empty file added tests/pytest/__init__.py
Empty file.
Empty file added tests/pytest/locale/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions tests/pytest/locale/test_formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from datetime import datetime

import pytest

from django.utils.formats import date_format

from benefits.locale.en.formats import DATE_FORMAT as DATE_FORMAT_EN
from benefits.locale.es.formats import DATE_FORMAT as DATE_FORMAT_ES


@pytest.fixture
def date_december():
return datetime(2024, 12, 1)


@pytest.fixture
def date_march():
return datetime(2024, 3, 1)


def test_en_DATE_FORMAT_december(date_december):
assert date_format(date_december, DATE_FORMAT_EN) == "December 1, 2024"


def test_en_DATE_FORMAT_march(date_march):
assert date_format(date_march, DATE_FORMAT_EN) == "March 1, 2024"


def test_es_DATE_FORMAT_december(settings, date_december):
settings.LANGUAGE_CODE = "es"
assert date_format(date_december, DATE_FORMAT_ES) == "1 de diciembre de 2024"


def test_es_DATE_FORMAT_march(settings, date_march):
settings.LANGUAGE_CODE = "es"
assert date_format(date_march, DATE_FORMAT_ES) == "1 de marzo de 2024"

0 comments on commit fecc1cc

Please sign in to comment.