Skip to content

Commit

Permalink
refactor(templates): replace hardcoded routes with context
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Aug 16, 2024
1 parent 9734177 commit 220f499
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 31 deletions.
3 changes: 1 addition & 2 deletions benefits/core/templates/core/agency-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
{% endblock title %}

{% block call-to-action %}
{% url "eligibility:index" as url_continue %}
<a href="{{ url_continue }}" class="btn btn-lg btn-primary">{% translate "Get Started" %}</a>
<a href="{% url routes.ELIGIBILITY_INDEX %}" class="btn btn-lg btn-primary">{% translate "Get Started" %}</a>
{% endblock call-to-action %}
4 changes: 2 additions & 2 deletions benefits/core/templates/core/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<div class="container d-none d-lg-block">
<ul class="footer-links m-0 p-0 list-unstyled d-lg-flex gap-lg-4">
<li>
<a class="footer-link m-0 p-0" href="{% url "core:help" %}">{% translate "Help" %}</a>
<a class="footer-link m-0 p-0" href="{% url routes.HELP %}">{% translate "Help" %}</a>
</li>
<li>
<a class="footer-link m-0 p-0" href="https://cdt.ca.gov/privacy-policy/" target="_blank" rel="noopener noreferrer">{% translate "Privacy Policy" %}</a>
Expand All @@ -117,7 +117,7 @@
<div class="d-block d-lg-none container">
<ul class="col-12 footer-links ps-0 mb-0">
<li>
<a class="footer-link" href="{% url "core:help" %}">{% translate "Help" %}</a>
<a class="footer-link" href="{% url routes.HELP %}">{% translate "Help" %}</a>
</li>
</ul>
</div>
Expand Down
3 changes: 1 addition & 2 deletions benefits/core/templates/core/includes/button--index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% load i18n %}

{% url "core:index" as href %}
{% translate "Return home" as default_button_text %}

<a href="{{ href }}" class="btn btn-lg btn-primary">{{ button_text | default:default_button_text }}</a>
<a href="{% url routes.INDEX %}" class="btn btn-lg btn-primary">{{ button_text | default:default_button_text }}</a>
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% load i18n %}

{% if authentication.logged_in %}
{% url "oauth:logout" as sign_out_url %}
<a href="{{ sign_out_url }}" class="login p-0 btn btn-lg" role="button">
<a href="{% url routes.OAUTH_LOGOUT %}" class="login p-0 btn btn-lg" role="button">
<span class="fallback-text color-logo">Login.gov</span>
</a>
{% endif %}
3 changes: 1 addition & 2 deletions benefits/core/templates/core/includes/link--sign-out.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{% if authentication.logged_in %}
{% url "oauth:logout" as signout_url %}
<div class="w-100 position-absolute">
<div class="container">
<div class="row nav-button-row">
<div class="col-12 d-flex align-items-center justify-content-end">
<a class="signout-link" href="{{ signout_url }}">
<a class="signout-link" href="{% url routes.OAUTH_LOGOUT %}">
{% block button_text %}
{% endblock button_text %}
</a>
Expand Down
2 changes: 1 addition & 1 deletion benefits/core/templates/core/includes/nocookies.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="navbar-brand">{% translate "Cookies are disabled" %}</span>
<span class="navbar-text">
{% translate "To function properly, this website requires a browser that supports cookies. Please enable cookies for this website and" %}
<a href="{% url "core:index" %}">{% translate "Return home" %}</a>.
<a href="{% url routes.INDEX %}">{% translate "Return home" %}</a>.
</span>
</div>
{% endblock content %}
2 changes: 1 addition & 1 deletion benefits/core/templates/core/includes/noscript.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="navbar-brand">{% translate "JavaScript is disabled" %}</span>
<span class="navbar-text">
{% translate "To function properly, this website requires a browser that supports JavaScript. Please enable JavaScript for this website and" %}
<a href="{% url "core:index" %}">{% translate "Return home" %}</a>.
<a href="{% url routes.INDEX %}">{% translate "Return home" %}</a>.
</span>
</div>
{% endblock content %}
2 changes: 1 addition & 1 deletion benefits/eligibility/templates/eligibility/confirm.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% endblock page-title %}

{% block nav-buttons %}
{% url "eligibility:start" as url_previous %}
{% url routes.ELIGIBILITY_START as url_previous %}
{% include "core/includes/button--previous-page.html" with url=url_previous %}
{% endblock nav-buttons %}

Expand Down
2 changes: 1 addition & 1 deletion benefits/eligibility/templates/eligibility/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% endblock page-title %}

{% block nav-buttons %}
{% url "core:index" as url %}
{% url routes.INDEX as url %}
{% include "core/includes/button--previous-page.html" with url=url %}
{% endblock nav-buttons %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ <h1>{% translate "You selected a CalFresh Cardholder transit benefit." %}</h1>
{% block call-to-action %}
<div class="row d-flex justify-content-lg-end">
<div class="col-lg-4 offset-2 offset-lg-0 col-sm-8 col-8 d-flex justify-content-lg-end justify-content-center">
{% url "oauth:login" as button_url %}
{% translate "Get started with" as button_text %}
<a href="{{ button_url }}" class="btn btn-lg btn-primary login">
<a href="{% url routes.OAUTH_LOGIN %}" class="btn btn-lg btn-primary login">
{{ button_text }} <span class="fallback-text white-logo">Login.gov</span>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ <h1>{% translate "You selected an Agency Card transit benefit." %}</h1>
{% block call-to-action %}
<div class="row d-flex justify-content-lg-end">
<div class="col-lg-3 offset-2 offset-sm-2 offset-lg-0 col-sm-8 col-8">
{% url "eligibility:confirm" as button_url %}
<a href="{{ button_url }}" class="btn btn-lg btn-primary" role="button">{% translate "Continue" %}</a>
<a href="{% url routes.ELIGIBILITY_CONFIRM %}" class="btn btn-lg btn-primary" role="button">{% translate "Continue" %}</a>
</div>
</div>
{% endblock call-to-action %}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ <h1>{% translate "You selected a Courtesy Card transit benefit." %}</h1>
{% block call-to-action %}
<div class="row d-flex justify-content-lg-end">
<div class="col-lg-3 offset-2 offset-sm-2 offset-lg-0 col-sm-8 col-8">
{% url "eligibility:confirm" as button_url %}
<a href="{{ button_url }}" class="btn btn-lg btn-primary" role="button">{% translate "Continue" %}</a>
<a href="{% url routes.ELIGIBILITY_CONFIRM %}" class="btn btn-lg btn-primary" role="button">{% translate "Continue" %}</a>
</div>
</div>
{% endblock call-to-action %}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ <h1>{% translate "You selected a Reduced Fare Mobility ID transit benefit." %}</
{% block call-to-action %}
<div class="row d-flex justify-content-lg-end">
<div class="col-lg-3 offset-2 offset-sm-2 offset-lg-0 col-sm-8 col-8">
{% url "eligibility:confirm" as button_url %}
<a href="{{ button_url }}" class="btn btn-lg btn-primary" role="button">{% translate "Continue" %}</a>
<a href="{% url routes.ELIGIBILITY_CONFIRM %}" class="btn btn-lg btn-primary" role="button">{% translate "Continue" %}</a>
</div>
</div>
{% endblock call-to-action %}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ <h1>{% translate "You selected an Older Adult transit benefit." %}</h1>
{% block call-to-action %}
<div class="row d-flex justify-content-lg-end">
<div class="col-lg-4 offset-2 offset-lg-0 col-sm-8 col-8 d-flex justify-content-lg-end justify-content-center">
{% url "oauth:login" as button_url %}
{% translate "Get started with" as button_text %}
<a href="{{ button_url }}" class="btn btn-lg btn-primary login">
<a href="{% url routes.OAUTH_LOGIN %}" class="btn btn-lg btn-primary login">
{{ button_text }} <span class="fallback-text white-logo">Login.gov</span>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ <h1>{% translate "You selected a Veteran transit benefit." %}</h1>
{% block call-to-action %}
<div class="row d-flex justify-content-lg-end">
<div class="col-lg-4 offset-2 offset-lg-0 col-sm-8 col-8 d-flex justify-content-lg-end justify-content-center">
{% url "oauth:login" as button_url %}
{% translate "Get started with" as button_text %}
<a href="{{ button_url }}" class="btn btn-lg btn-primary login">
<a href="{% url routes.OAUTH_LOGIN %}" class="btn btn-lg btn-primary login">
{{ button_text }} <span class="fallback-text white-logo">Login.gov</span>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion benefits/eligibility/templates/eligibility/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% endblock classes %}

{% block nav-buttons %}
{% url "eligibility:index" as url %}
{% url routes.ELIGIBILITY_INDEX as url %}
{% include "core/includes/button--previous-page.html" with url=url %}
{% endblock nav-buttons %}

Expand Down
3 changes: 1 addition & 2 deletions benefits/enrollment/templates/enrollment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ <h1 class="pb-lg-8 pb-4">
This Javascript code is partially generated by this template and so it must
come before the forms, which are rendered at just before the {% endblock inner-content %}
{% endcomment %}
{% url "enrollment:token" as access_token_url %}
{% translate "Please wait..." as loading_text %}
<script nonce="{{ request.csp_nonce }}">
var startedEvent = "started payment connection", closedEvent = "closed payment connection";

$.ajax({ dataType: "script", attrs: { nonce: "{{ request.csp_nonce }}"}, url: "{{ card_tokenize_url }}" })
.done(function() {
$.get("{{ access_token_url }}", function(data) {
$.get("{% url routes.ENROLLMENT_TOKEN %}", function(data) {
if (data.redirect) {
// https://stackoverflow.com/a/42469170
// use 'assign' because 'replace' was giving strange Back button behavior
Expand Down
3 changes: 1 addition & 2 deletions benefits/enrollment/templates/enrollment/system_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ <h1 class="h2 text-center">
<div class="row pt-8 justify-content-center">
<div class="col-lg-3 col-8">
{% if authentication and authentication.sign_out_link_template %}
{% url "oauth:logout" as sign_out_url %}
{% translate "Sign out of" as button_text %}
<a href="{{ sign_out_url }}" class="btn btn-lg btn-primary login">
<a href="{% url routes.OAUTH_LOGOUT %}" class="btn btn-lg btn-primary login">
{{ button_text }} <span class="fallback-text white-logo">Login.gov</span>
</a>
{% else %}
Expand Down

0 comments on commit 220f499

Please sign in to comment.