diff --git a/app/__init__.py b/app/__init__.py index 9ec056c2b..af9b3f9a9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -54,6 +54,7 @@ from app.formatters import ( format_datetime_normal, format_datetime_relative, format_datetime_short, + format_datetime_short_america, format_day_of_week, format_delta, format_delta_days, @@ -548,6 +549,7 @@ def add_template_filters(application): format_datetime_24h, format_datetime_normal, format_datetime_short, + format_datetime_short_america, valid_phone_number, linkable_name, format_date, diff --git a/app/formatters.py b/app/formatters.py index 86c187f55..eefd20666 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -97,6 +97,20 @@ def format_datetime_short(date): format_date_short(date), format_time_24h(date), get_user_preferred_timezone() ) +def format_datetime_short_america(date): + return "{} at {} {}".format( + format_date_normal_america(date), format_time_12h(date),get_user_preferred_timezone() + ) + +def format_date_normal_america(date): + date = parse_naive_dt(date) + return date.strftime("%B %d, %Y").lstrip("0") + +def format_time_12h(date): + date = parse_naive_dt(date) + + preferred_tz = pytz.timezone(get_user_preferred_timezone()) + return date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%I:%M %p") def format_datetime_relative(date): return "{} at {} {}".format( diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index a93c1680a..3ccc39403 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -54,22 +54,21 @@ def service_dashboard(service_id): job_response = job_api_client.get_jobs(service_id) service_data_retention_days = 7 - jobs = [] - for job in job_response['data']: - job_info = { - "job_id": job["id"], - "time_left": get_time_left(job["created_at"]), - "download_link": url_for(".view_job_csv", service_id=current_service.id, job_id=job["id"]), - "notification_count": job["notification_count"], + jobs = [ + { + "job_id": job["id"], + "time_left": get_time_left(job["created_at"]), + "download_link": url_for(".view_job_csv", service_id=current_service.id, job_id=job["id"]), + "notification_count": job["notification_count"], } - jobs.append(job_info) + for job in job_response.get('data', []) + ] return render_template( "views/dashboard/dashboard.html", updates_url=url_for(".service_dashboard_updates", service_id=service_id), partials=get_dashboard_partials(service_id), notifications=notifications, jobs=jobs, - job_response = job_response, service_data_retention_days=service_data_retention_days, ) diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 1ad2632ca..a9cc8f5cf 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -48,10 +48,10 @@ {{ item.template.name }} {% endcall %} {% call row_heading() %} - {{ item.status|format_notification_status_as_time( - item.created_at|format_datetime_short, - (item.updated_at or item.created_at)|format_datetime_short) - }} + {{ item.status|format_notification_status_as_time( + item.created_at|format_datetime_short_america, + (item.updated_at or item.created_at)|format_datetime_short_america + ) }} {% endcall %} {% call row_heading() %} {{ item.created_by.name }}