Count recently-returned letters on the dashboard

Currently you have no way of getting to the returned letter page. This
commit adds a link to it from the dashboard, following the pattern of
the new received text messages banner.
This commit is contained in:
Chris Hill-Scott
2020-02-12 14:19:21 +00:00
parent 74e70ed8bc
commit f369f76ae4
7 changed files with 218 additions and 8 deletions

View File

@@ -356,6 +356,22 @@ def format_delta(date):
)
def format_delta_days(date):
now = datetime.now(timezone.utc)
date = utc_string_to_aware_gmt_datetime(date)
delta = now - date
if date.strftime('%Y-%M-%D') == now.strftime('%Y-%M-%D'):
return "today"
if date.strftime('%Y-%M-%D') == (now - timedelta(days=1)).strftime('%Y-%M-%D'):
return "yesterday"
return ago.human(
delta,
precision=1,
future_tense='{} from now',
past_tense='{} ago',
)
def valid_phone_number(phone_number):
try:
validate_phone_number(phone_number)
@@ -744,6 +760,7 @@ def add_template_filters(application):
format_date_short,
format_datetime_relative,
format_delta,
format_delta_days,
format_notification_status,
format_notification_type,
format_notification_status_as_time,