From cadc700712d6f2e3ab458615182e1ca473059b2d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 14 Apr 2016 13:35:56 +0100 Subject: [PATCH] Remove human-friendly timestamps from activity page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix introduced by e6490e1 did not fix anything. So lets remove the ‘3 days ago’ thing completely and just say the date and time instead. --- app/__init__.py | 18 +++++++----------- app/templates/views/notifications.html | 2 +- requirements.txt | 1 - 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 09be293f1..1cd8f884b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -21,7 +21,6 @@ from pygments import highlight from pygments.lexers import JavascriptLexer from pygments.formatters import HtmlFormatter from werkzeug.exceptions import abort -import humanize from app.notify_client.api_client import ServiceAPIClient from app.notify_client.api_key_api_client import ApiKeyApiClient @@ -97,12 +96,12 @@ def create_app(): application.add_template_filter(nl2br) application.add_template_filter(format_datetime) + application.add_template_filter(format_datetime_short) application.add_template_filter(format_time) application.add_template_filter(syntax_highlight_json) application.add_template_filter(valid_phone_number) application.add_template_filter(linkable_name) application.add_template_filter(format_date) - application.add_template_filter(format_delta) application.after_request(useful_headers_after_request) application.after_request(save_service_after_request) @@ -177,6 +176,12 @@ def format_datetime(date): return native.strftime('%A %d %B %Y at %H:%M') +def format_datetime_short(date): + date = dateutil.parser.parse(date) + native = date.replace(tzinfo=None) + return native.strftime('%d %B at %H:%M') + + def format_time(date): date = dateutil.parser.parse(date) native = date.replace(tzinfo=None) @@ -188,15 +193,6 @@ def format_date(date): return date.strftime('%A %d %B %Y') -def format_delta(date): - date = dateutil.parser.parse(date) - native = date.replace(tzinfo=None) - difference = datetime.datetime.now() - native - return humanize.naturaltime( - datetime.timedelta(seconds=difference.total_seconds()) - ) - - def valid_phone_number(phone_number): try: validate_phone_number(phone_number) diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index ba7abc7ad..02743791e 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -96,7 +96,7 @@ {{ text_field(item.status|capitalize) }} {% call field(align='right') %} - {{ item.created_at|format_delta|capitalize }} + {{ item.created_at|format_datetime_short }} {% endcall %} {% endcall %} diff --git a/requirements.txt b/requirements.txt index 00484939c..3b1b1088c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,6 @@ Flask-Bcrypt==0.6.2 credstash==1.8.0 boto3==1.2.3 Pygments==2.0.2 -humanize==0.5.1 git+https://github.com/alphagov/notifications-python-client.git@0.3.1#egg=notifications-python-client==0.3.1