Skip to content

Commit

Permalink
Merge pull request #8425 from cfpb/retirement-spanish-urls
Browse files Browse the repository at this point in the history
Retirement spanish urls
  • Loading branch information
wpears authored May 17, 2024
2 parents 63510f0 + e291951 commit d926053
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 45 deletions.
7 changes: 4 additions & 3 deletions cfgov/apache/conf.d/redirects.conf
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,13 @@ RedirectMatch permanent (.*)/realestateprofessionals(.*) $1/real-estate-profess
RedirectMatch permanent ^/real-estate[/]?$ /know-before-you-owe/real-estate-professionals/

# Retirement redirects
RedirectMatch permanent (?i)^/retirement/claiming-social-security/?$ /retirement/before-you-claim/
RedirectMatch permanent (?i)^/jubilacion/?$ /retirement/before-you-claim/es/
RedirectMatch permanent (?i)^/retirement/?$ /retirement/before-you-claim/
RedirectMatch permanent (?i)^/retirement/claiming-social-security/?$ /consumer-tools/retirement/before-you-claim/
RedirectMatch permanent (?i)^/jubilacion/?$ /es/herramientas-del-consumidor/jubilacion/antes-de-solicitar/
RedirectMatch permanent (?i)^/retirement/?$ /consumer-tools/retirement/before-you-claim/

# Redirect from /es/ suffix urls
RedirectMatch permanent (?i)^/consumer-tools/financial-well-being/es/ /es/herramientas-del-consumidor/bienestar-financiero/
RedirectMatch permanent (?i)^/consumer-tools/retirement/before-you-claim/es/ /es/herramientas-del-consumidor/jubilacion/antes-de-solicitar/

# Owning a Home redirects
RewriteRule ^owningahome$ /owning-a-home$1 [L,R=301]
Expand Down
4 changes: 4 additions & 0 deletions cfgov/cfgov/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def empty_200_response(request, *args, **kwargs):
r"^consumer-tools/retirement/",
include("retirement_api.urls", namespace="retirement_api"),
),
re_path(
r"^es/herramientas-del-consumidor/jubilacion/",
include("retirement_api.es_urls", namespace="retirement_api_es"),
),
# CCDB5-API
re_path(
r"^data-research/consumer-complaints/search/api/v1/",
Expand Down
33 changes: 33 additions & 0 deletions cfgov/retirement_api/es_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from core.views import TranslatedTemplateView
from retirement_api.views import estimator


try:
from django.urls import re_path
except ImportError:
from django.conf.urls import url as re_path

app_name = "retirement_api_es"

urlpatterns = [
re_path(
r"^before-you-claim/mas-sobre/$",
TranslatedTemplateView.as_view(
template_name="retirement_api/about.html", language="es"
),
name="about",
),
re_path(
r"^antes-de-solicitar/$",
TranslatedTemplateView.as_view(
template_name="retirement_api/claiming-es.html", language="es"
),
name="claiming",
),
re_path(
r"^retirement-api/estimator/(?P<dob>[^/]+)/(?P<income>\d+)/$",
estimator,
{"language": "es"},
name="estimator",
),
]
13 changes: 13 additions & 0 deletions cfgov/retirement_api/jinja2/retirement_api/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ <h1>
<h2>
{{ _("Planning your Social Security claiming age") }}
</h2>
{% import 'v1/includes/molecules/translation-links.html' as translation_links with context %}
{{ translation_links.render(
links=[
{
'href': url('retirement_api_en:about'),
'language': 'en',
'text': 'English'
},{
'href': url('retirement_api_es:about'),
'language': 'es',
'text': 'Spanish'
}]
) }}
<h3>
{{ _("How do we generate your estimates?") }}
</h3>
Expand Down
7 changes: 3 additions & 4 deletions cfgov/retirement_api/jinja2/retirement_api/claiming.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ <h1>{{ _("Planning your Social Security claiming age") }}</h1>
<p class="lead-paragraph">
{{ _("The age you claim Social Security affects your lifetime income. We’ll help you think through this decision.") }}
</p>

{% import 'v1/includes/molecules/translation-links.html' as translation_links with context %}
{{ translation_links.render(
links=[
{
'href': '../',
'href': url('retirement_api_en:claiming'),
'language': 'en',
'text': 'English'
},{
'href': 'es/',
'href': url('retirement_api_es:claiming'),
'language': 'es',
'text': 'Spanish'
}]
Expand Down Expand Up @@ -194,7 +193,7 @@ <h3 class="retirement-age">{{ _("About your early benefit claiming age:") }}</h3
</div>

<p class="learn-how">
<a href="/consumer-tools/retirement/before-you-claim/about/{{ 'es/' if language == 'es' }}"
<a href="{{url('retirement_api_' + current_language + ':about')}}"
target="_blank" rel="noopener noreferrer">
{{ _("Where do these numbers come from?") }}
</a>
Expand Down
8 changes: 4 additions & 4 deletions cfgov/retirement_api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class ViewTests(TestCase):
return_keys = ["data", "error"]

def test_base_view(self):
url = reverse("retirement_api:claiming_en")
url = reverse("retirement_api_en:claiming")
response = self.client.get(url)
self.assertTrue(response.status_code == 200)
url = reverse("retirement_api:claiming_es")
url = reverse("retirement_api_en:claiming")
response = self.client.get(url)
self.assertTrue(response.status_code == 200)

Expand Down Expand Up @@ -127,9 +127,9 @@ def test_estimator_query_data_bad_income(self):
self.assertTrue(response.status_code == 400)

def test_about_pages(self):
url = reverse("retirement_api:retirement_about_en")
url = reverse("retirement_api_en:about")
response = self.client.get(url)
self.assertTrue(response.status_code == 200)
url = reverse("retirement_api:retirement_about_es")
url = reverse("retirement_api_es:about")
response = self.client.get(url)
self.assertTrue(response.status_code == 200)
27 changes: 3 additions & 24 deletions cfgov/retirement_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,26 @@
except ImportError:
from django.conf.urls import url as re_path


app_name = "retirement_api"
app_name = "retirement_api_en"

urlpatterns = [
re_path(
r"^before-you-claim/about/$",
TranslatedTemplateView.as_view(
template_name="retirement_api/about.html", language="en"
),
name="retirement_about_en",
),
re_path(
r"^before-you-claim/about/es/$",
TranslatedTemplateView.as_view(
template_name="retirement_api/about.html", language="es"
),
name="retirement_about_es",
name="about",
),
re_path(
r"^before-you-claim/$",
TranslatedTemplateView.as_view(
template_name="retirement_api/claiming.html", language="en"
),
name="claiming_en",
),
re_path(
r"^before-you-claim/es/$",
TranslatedTemplateView.as_view(
template_name="retirement_api/claiming-es.html", language="es"
),
name="claiming_es",
name="claiming",
),
re_path(
r"^retirement-api/estimator/(?P<dob>[^/]+)/(?P<income>\d+)/$",
estimator,
name="estimator",
),
re_path(
r"^retirement-api/estimator/(?P<dob>[^/]+)/(?P<income>\d+)/es/$",
estimator,
{"language": "es"},
name="estimator_es",
),
]
9 changes: 2 additions & 7 deletions cfgov/unprocessed/apps/retirement/js/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@ export let lifetime = {};
/**
* @param {string} birthdate - Birthday in MM-DD-YYYY format
* @param {number} salary - Entered salary as a number
* @param {string} dataLang - Language
* @returns {Promise} A promise that resolved to the parsed response
*/
export function fetchApiData(birthdate, salary, dataLang) {
export function fetchApiData(birthdate, salary) {
if (typeof birthdate !== 'string' || typeof salary !== 'number')
throw new Error('Invalid API call');
let url = `../retirement-api/estimator/${birthdate}/${salary}/`;

if (dataLang === 'es') {
url = `../${url}es/`;
}
const url = `../retirement-api/estimator/${birthdate}/${salary}/`;

return fetch(url).then((v) => v.json());
}
Expand Down
3 changes: 1 addition & 2 deletions cfgov/unprocessed/apps/retirement/js/views/graph-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ function validateBirthdayFields() {
* using a variety of view-updating functions.
*/
function getYourEstimates() {
const dataLang = document.querySelector('html').getAttribute('lang');
const dates = validateBirthdayFields();
const salaryInputElm = document.querySelector('#salary-input');
const salary = convertStringToNumber(salaryInputElm.value);
Expand All @@ -251,7 +250,7 @@ function getYourEstimates() {
highlightAgeFields(false);
const loadIndDom = document.querySelector('#api-data-loading-indicator');
loadIndDom.style.display = 'inline-block';
fetchApiData(dates.concat, salary, dataLang).then((resp) => {
fetchApiData(dates.concat, salary).then((resp) => {
if (resp.error === '') {
updateDataFromApi(resp);
$('.step-two .question').css('display', 'inline-block');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Planning your Social Security', () => {
//*******************************************/
//**********Language Selection***************/
it('should have a spanish view', () => {
cy.intercept('/consumer-tools/retirement/before-you-claim/es').as(
cy.intercept('/es/herramientas-del-consumidor/jubilacion/antes-de-solicitar/').as(
'getSpanish',
);
claim.setLanguageToSpanish();
Expand Down

0 comments on commit d926053

Please sign in to comment.