From fa0a7f16626b02180e4c42fc2b7107a8b55f5e5d Mon Sep 17 00:00:00 2001 From: Kanwei Li Date: Mon, 3 Aug 2009 18:57:13 -0400 Subject: [PATCH] Grid: Age -> Created, for dates further than a week ago, display actual date --- lib/galaxy/web/controllers/history.py | 4 ++-- lib/galaxy/web/framework/helpers/__init__.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/web/controllers/history.py b/lib/galaxy/web/controllers/history.py index 5bd7cd51786..228f86af041 100644 --- a/lib/galaxy/web/controllers/history.py +++ b/lib/galaxy/web/controllers/history.py @@ -47,8 +47,8 @@ class HistoryListGrid( grids.Grid ): attach_popup=True ), DatasetsByStateColumn( "Datasets (by state)", ncells=4 ), StatusColumn( "Status", attach_popup=False ), - grids.GridColumn( "Age", key="create_time", format=time_ago ), - grids.GridColumn( "Last update", key="update_time", format=time_ago ), + grids.GridColumn( "Created", key="create_time", format=time_ago ), + grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), # Valid for filtering but invisible grids.GridColumn( "Deleted", key="deleted", visible=False ) ] diff --git a/lib/galaxy/web/framework/helpers/__init__.py b/lib/galaxy/web/framework/helpers/__init__.py index 2d2bc250779..c04ad350020 100644 --- a/lib/galaxy/web/framework/helpers/__init__.py +++ b/lib/galaxy/web/framework/helpers/__init__.py @@ -3,10 +3,16 @@ import pkg_resources pkg_resources.require( "WebHelpers" ) from webhelpers import * -from datetime import datetime +from datetime import datetime, timedelta +# If the date is more than one week ago, then display the actual date instead of in words def time_ago( x ): - return date.distance_of_time_in_words( x, datetime.utcnow() ) + delta = timedelta(weeks=1) + + if (datetime.utcnow() - x) > delta: # Greater than a week difference + return x.strftime("%b %d, %Y") + else: + return date.distance_of_time_in_words( x, datetime.utcnow() ) + " ago" def iff( a, b, c ): if a: