Skip to content

Commit

Permalink
BB2-2874 Add localization to access end date format
Browse files Browse the repository at this point in the history
* Add localization so that date format changes when language is Spanish
  • Loading branch information
Sharon Su committed Dec 27, 2023
1 parent c31682e commit f2af83f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions apps/dot_ext/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,22 @@ class Application(AbstractApplication):
verbose_name="Data Access Type:",
)

def access_end_date_mesg(self):
# Text and date must be separated so that built-in Django localization
# will recognize that the date should be localized when tagged
def access_end_date_text(self):
if self.has_one_time_only_data_access():
return TEN_HOURS
elif "RESEARCH_STUDY" in self.data_access_type:
return "no end date."
else:
return "until "

def access_end_date(self):
if self.data_access_type == "THIRTEEN_MONTH":
end_date = datetime.now() + relativedelta(months=+13)
return "until " + end_date.strftime("%B %d, %Y")
return end_date.date
else:
return None

def scopes(self):
scope_list = []
Expand Down
3 changes: 2 additions & 1 deletion apps/dot_ext/views/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def __init__(self, version=1):

def get_context_data(self, **kwargs):
context = super(AuthorizationView, self).get_context_data(**kwargs)
context['permission_end_date'] = self.application.access_end_date_mesg()
context['permission_end_date_text'] = self.application.access_end_date_text()
context['permission_end_date'] = self.application.access_end_date()
return context

def dispatch(self, request, *args, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion templates/design_system/new_authorize_v2.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "auth_base.html" %}
{% load static %}
{% load i18n %}
{% load l10n %}
{% load bootstrap %}

{% block navigation %}{% endblock %}
Expand Down Expand Up @@ -141,7 +142,7 @@ <h1 class="ds-text-heading--2xl ds-u-margin-bottom--3">Connect your Medicare cla
</g>
</g>
</g>
</svg><span class="ds-u-margin-left--3 ds-text-body--md">{{ application.name }} will have access to your data {{ permission_end_date }}.</span>
</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>
</p>
{% endif %}
<p class="ds-u-margin-top--5 ds-u-margin-bottom--0" style="display: flex; align-items: center">
Expand Down

0 comments on commit f2af83f

Please sign in to comment.