-
Notifications
You must be signed in to change notification settings - Fork 10
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: simplify Eligibility Start templates #2726
Changes from all commits
4d8a579
ed22fec
0b3c428
6e067f9
25bc8e4
2b6dbb5
e5f9e57
57f2faf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 5.1.7 on 2025-03-13 18:22 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0037_remove_transitagency_eligibility_index_template_override"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="enrollmentflow", | ||
name="eligibility_start_template_override", | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .agency import eligibility_index | ||
from .flow import eligibility_start | ||
|
||
__all__ = ["eligibility_index"] | ||
__all__ = ["eligibility_index", "eligibility_start"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from dataclasses import dataclass, asdict | ||
from typing import Optional | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from benefits.core.context import SystemName | ||
from benefits.routes import routes | ||
|
||
|
||
@dataclass | ||
class CTAButton: | ||
text: str | ||
route: str | ||
fallback_text: Optional[str] = None | ||
extra_classes: Optional[str] = None | ||
|
||
|
||
@dataclass | ||
class EligibilityStart: | ||
page_title: str | ||
headline_text: str | ||
eligibility_item_template: str | ||
call_to_action_button: CTAButton | ||
|
||
def dict(self): | ||
return asdict(self) | ||
|
||
|
||
class LoginGovEligibilityStart(EligibilityStart): | ||
def __init__(self, page_title, headline_text): | ||
super().__init__( | ||
page_title=page_title, | ||
headline_text=headline_text, | ||
eligibility_item_template="eligibility/includes/eligibility-item--identification--start--login-gov.html", | ||
call_to_action_button=CTAButton( | ||
text=_("Get started with"), fallback_text="Login.gov", route=routes.OAUTH_LOGIN, extra_classes="login" | ||
), | ||
) | ||
|
||
|
||
class AgencyCardEligibilityStart(EligibilityStart): | ||
def __init__(self, headline_text, eligibility_item_template): | ||
super().__init__( | ||
page_title=_("Agency card overview"), | ||
headline_text=headline_text, | ||
eligibility_item_template=eligibility_item_template, | ||
call_to_action_button=CTAButton(text=_("Continue"), route=routes.ELIGIBILITY_CONFIRM), | ||
) | ||
|
||
|
||
eligibility_start = { | ||
SystemName.AGENCY_CARD.value: AgencyCardEligibilityStart( | ||
headline_text=_("You selected an Agency Card transit benefit."), | ||
eligibility_item_template="eligibility/includes/eligibility-item--identification--start--cst-agency-card.html", | ||
), | ||
SystemName.CALFRESH.value: LoginGovEligibilityStart( | ||
page_title=_("CalFresh benefit overview"), headline_text=_("You selected a CalFresh Cardholder transit benefit.") | ||
), | ||
SystemName.COURTESY_CARD.value: AgencyCardEligibilityStart( | ||
headline_text=_("You selected a Courtesy Card transit benefit."), | ||
eligibility_item_template="eligibility/includes/eligibility-item--identification--start--mst-agency-card.html", | ||
), | ||
SystemName.MEDICARE.value: EligibilityStart( | ||
page_title=_("Medicare benefit overview"), | ||
headline_text=_("You selected a Medicare Cardholder transit benefit."), | ||
eligibility_item_template="eligibility/includes/eligibility-item--identification--start--medicare.html", | ||
call_to_action_button=CTAButton(text=_("Continue to Medicare.gov"), route=routes.OAUTH_LOGIN), | ||
), | ||
SystemName.OLDER_ADULT.value: LoginGovEligibilityStart( | ||
page_title=_("Older Adult benefit overview"), | ||
headline_text=_("You selected an Older Adult transit benefit."), | ||
), | ||
SystemName.REDUCED_FARE_MOBILITY_ID.value: AgencyCardEligibilityStart( | ||
headline_text=_("You selected a Reduced Fare Mobility ID transit benefit."), | ||
eligibility_item_template="eligibility/includes/eligibility-item--identification--start--sbmtd-agency-card.html", | ||
), | ||
SystemName.VETERAN.value: LoginGovEligibilityStart( | ||
page_title=_("Veterans benefit overview"), headline_text=_("You selected a Veteran transit benefit.") | ||
), | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,26 +5,34 @@ | |
{{ block.super | add:" eligibility-start" }} | ||
{% endblock classes %} | ||
|
||
{% block page-title %} | ||
{% translate page_title %} | ||
{% endblock page-title %} | ||
|
||
{% block nav-buttons %} | ||
{% url routes.ELIGIBILITY_INDEX as url %} | ||
{% include "core/includes/button--previous-page.html" with url=url %} | ||
{% endblock nav-buttons %} | ||
|
||
{% block headline %} | ||
<h1> | ||
{% block headline-text %} | ||
{% endblock headline-text %} | ||
</h1> | ||
<h1>{{ headline_text }}</h1> | ||
{% endblock headline %} | ||
|
||
{% block inner-content %} | ||
<p class="py-4">{% translate "You will need a few items to continue:" %}</p> | ||
<ul class="d-flex flex-column gap-4 list-unstyled ps-0 mb-0"> | ||
{% block eligibility-item %} | ||
{% endblock eligibility-item %} | ||
{% include eligibility_item_template %} | ||
{% include "eligibility/includes/eligibility-item--contactless-card--start.html" %} | ||
</ul> | ||
{% endblock inner-content %} | ||
|
||
{% block call-to-action-button %} | ||
{% translate call_to_action_button.text as button_text %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something I was wondering about when working on #2753: Since we already use the I think the answer, from #2753 anyway, seems to be: no. You can just render the variable directly in the template and it will be translated as necessary. E.g. this template change: https://github.com/cal-itp/benefits/pull/2753/files#diff-70ed6fd5fa2321e83db0d63df8312f680cd40428de4ada50dab22e93f55db7c7R109 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that we can remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking to merge this PR as-is, and a follow-up PR can remove the unnecessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #2760 as that follow-up ticket |
||
<a href="{% url call_to_action_button.route %}" | ||
class="btn btn-lg btn-primary{% if call_to_action_button.extra_classes %} {{ call_to_action_button.extra_classes }}{% endif %}"> | ||
{{ button_text }} | ||
{% if call_to_action_button.fallback_text %} | ||
<span class="fallback-text white-logo">{{ call_to_action_button.fallback_text }}</span> | ||
{% endif %} | ||
</a> | ||
{% endblock call-to-action-button %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can take a follow-up item to refactor this field away from using these templates, and to encode the item strings directly in context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, great idea! Created #2759 for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it in the sprint, but feel free to change that if you disagree