mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Grid: Age -> Created, for dates further than a week ago, display actual date
This commit is contained in:
@@ -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 )
|
||||
]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user