Skip to content

Commit b4a1cce

Browse files
authored
BB2-2874 Add localization to access end date format (#1157)
* Add localization so that date format changes when language is Spanish
1 parent b964805 commit b4a1cce

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

apps/dot_ext/models.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,22 @@ class Application(AbstractApplication):
158158
verbose_name="Data Access Type:",
159159
)
160160

161-
def access_end_date_mesg(self):
161+
# Text and date must be separated so that built-in Django localization
162+
# will recognize that the date should be localized when tagged
163+
def access_end_date_text(self):
162164
if self.has_one_time_only_data_access():
163165
return TEN_HOURS
164166
elif "RESEARCH_STUDY" in self.data_access_type:
165167
return "no end date."
166168
else:
169+
return "until "
170+
171+
def access_end_date(self):
172+
if self.data_access_type == "THIRTEEN_MONTH":
167173
end_date = datetime.now() + relativedelta(months=+13)
168-
return "until " + end_date.strftime("%B %d, %Y")
174+
return end_date.date
175+
else:
176+
return None
169177

170178
def scopes(self):
171179
scope_list = []

apps/dot_ext/views/authorization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def __init__(self, version=1):
6565

6666
def get_context_data(self, **kwargs):
6767
context = super(AuthorizationView, self).get_context_data(**kwargs)
68-
context['permission_end_date'] = self.application.access_end_date_mesg()
68+
context['permission_end_date_text'] = self.application.access_end_date_text()
69+
context['permission_end_date'] = self.application.access_end_date()
6970
return context
7071

7172
def dispatch(self, request, *args, **kwargs):

templates/design_system/new_authorize_v2.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends "auth_base.html" %}
22
{% load static %}
33
{% load i18n %}
4+
{% load l10n %}
45
{% load bootstrap %}
56

67
{% block navigation %}{% endblock %}
@@ -141,7 +142,7 @@ <h1 class="ds-text-heading--2xl ds-u-margin-bottom--3">Connect your Medicare cla
141142
</g>
142143
</g>
143144
</g>
144-
</svg><span class="ds-u-margin-left--3 ds-text-body--md">{{ application.name }} will have access to your data {{ permission_end_date }}.</span>
145+
</svg><span class="ds-u-margin-left--3 ds-text-body--md">{{ application.name }} will have access to your data {{ permission_end_date_text }}{% if permission_end_date is not None %}{{ permission_end_date|localize }}{% endif %}.</span>
145146
</p>
146147
{% endif %}
147148
<p class="ds-u-margin-top--5 ds-u-margin-bottom--0" style="display: flex; align-items: center">

0 commit comments

Comments
 (0)