galaxy-dist commit 9bcd722236bd: Refactoring of grid framework in preparation for enhancing sorting. Removed unused keyword 'encoded_sort_key' and made all GridColumn constructor keyword parameters explicit.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User jeremy goecks <jeremy.goecks@emory.edu> # Date 1282492757 14400 # Node ID 9bcd722236bd7d74784d7317bbe53fa3f050d101 # Parent 3ab68d0ba173ea4b21317c79fdea907bd91f5a81 Refactoring of grid framework in preparation for enhancing sorting. Removed unused keyword 'encoded_sort_key' and made all GridColumn constructor keyword parameters explicit. --- a/lib/galaxy/web/controllers/dataset.py +++ b/lib/galaxy/web/controllers/dataset.py @@ -114,7 +114,7 @@ class HistoryDatasetAssociationListGrid( link=( lambda item: iff( item.history.deleted, None, dict( operation="switch", id=item.id ) ) ), filterable="advanced", attach_popup=True ), HistoryColumn( "History", key="history", link=( lambda item: iff( item.history.deleted, None, dict( operation="switch_history", id=item.id ) ) ) ), - grids.IndividualTagsColumn( "Tags", "tags", model.HistoryDatasetAssociation, model.HistoryDatasetAssociationTagAssociation, filterable="advanced", grid_name="HistoryDatasetAssocationListGrid" ), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.HistoryDatasetAssociation, model_tag_association_class=model.HistoryDatasetAssociationTagAssociation, filterable="advanced", grid_name="HistoryDatasetAssocationListGrid" ), StatusColumn( "Status", key="deleted", attach_popup=False ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), ] --- a/lib/galaxy/web/controllers/history.py +++ b/lib/galaxy/web/controllers/history.py @@ -44,7 +44,9 @@ class HistoryListGrid( grids.Grid ): link=( lambda history: iff( history.deleted, None, dict( operation="Switch", id=history.id ) ) ), attach_popup=True, filterable="advanced" ), DatasetsByStateColumn( "Datasets (by state)", ncells=4 ), - grids.IndividualTagsColumn( "Tags", "tags", model.History, model.HistoryTagAssociation, filterable="advanced", grid_name="HistoryListGrid" ), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.History, \ + model_tag_association_class=model.HistoryTagAssociation, \ + filterable="advanced", grid_name="HistoryListGrid" ), grids.SharingStatusColumn( "Sharing", key="sharing", model_class=model.History, filterable="advanced", sortable=False ), grids.GridColumn( "Created", key="create_time", format=time_ago ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), @@ -131,7 +133,7 @@ class HistoryAllPublishedGrid( grids.Gri NameURLColumn( "Name", key="name", model_class=model.History, filterable="advanced" ), grids.OwnerAnnotationColumn( "Annotation", key="annotation", model_class=model.History, model_annotation_association_class=model.HistoryAnnotationAssociation, filterable="advanced" ), grids.OwnerColumn( "Owner", key="username", model_class=model.User, filterable="advanced", sortable=False ), - grids.CommunityTagsColumn( "Community Tags", "tags", model.History, model.HistoryTagAssociation, filterable="advanced", grid_name="PublicHistoryListGrid" ), + grids.CommunityTagsColumn( "Community Tags", key="tags", model_class=model.History, model_tag_association_class=model.HistoryTagAssociation, filterable="advanced", grid_name="PublicHistoryListGrid" ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ) ] columns.append( --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -70,7 +70,7 @@ class StoredWorkflowAllPublishedGrid( gr grids.PublicURLColumn( "Name", key="name", model_class=model.StoredWorkflow, filterable="advanced" ), grids.OwnerAnnotationColumn( "Annotation", key="annotation", model_class=model.StoredWorkflow, model_annotation_association_class=model.StoredWorkflowAnnotationAssociation, filterable="advanced" ), grids.OwnerColumn( "Owner", key="username", model_class=model.User, filterable="advanced", sortable=False ), - grids.CommunityTagsColumn( "Community Tags", "tags", model.StoredWorkflow, model.StoredWorkflowTagAssociation, filterable="advanced", grid_name="PublicWorkflowListGrid" ), + grids.CommunityTagsColumn( "Community Tags", key="tags", model_class=model.StoredWorkflow, model_tag_association_class=model.StoredWorkflowTagAssociation, filterable="advanced", grid_name="PublicWorkflowListGrid" ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ) ] columns.append( --- a/lib/galaxy/web/controllers/visualization.py +++ b/lib/galaxy/web/controllers/visualization.py @@ -15,7 +15,7 @@ class VisualizationListGrid( grids.Grid grids.TextColumn( "Title", key="title", model_class=model.Visualization, attach_popup=True, link=( lambda item: dict( controller="tracks", action="browser", id=item.id ) ) ), grids.TextColumn( "Dbkey", key="dbkey", model_class=model.Visualization ), - grids.IndividualTagsColumn( "Tags", "tags", model.Visualization, model.VisualizationTagAssociation, filterable="advanced", grid_name="VisualizationListGrid" ), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.Visualization, model_tag_association_class=model.VisualizationTagAssociation, filterable="advanced", grid_name="VisualizationListGrid" ), grids.SharingStatusColumn( "Sharing", key="sharing", model_class=model.Visualization, filterable="advanced", sortable=False ), grids.GridColumn( "Created", key="create_time", format=time_ago ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), @@ -50,7 +50,7 @@ class VisualizationAllPublishedGrid( gri grids.PublicURLColumn( "Title", key="title", model_class=model.Visualization, filterable="advanced" ), grids.OwnerAnnotationColumn( "Annotation", key="annotation", model_class=model.Visualization, model_annotation_association_class=model.VisualizationAnnotationAssociation, filterable="advanced" ), grids.OwnerColumn( "Owner", key="username", model_class=model.User, filterable="advanced", sortable=False ), - grids.CommunityTagsColumn( "Community Tags", "tags", model.Visualization, model.VisualizationTagAssociation, filterable="advanced", grid_name="VisualizationAllPublishedGrid" ), + grids.CommunityTagsColumn( "Community Tags", key="tags", model_class=model.Visualization, model_tag_association_class=model.VisualizationTagAssociation, filterable="advanced", grid_name="VisualizationAllPublishedGrid" ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ) ] columns.append( --- a/lib/galaxy/web/controllers/page.py +++ b/lib/galaxy/web/controllers/page.py @@ -27,7 +27,8 @@ class PageListGrid( grids.Grid ): columns = [ grids.TextColumn( "Title", key="title", model_class=model.Page, attach_popup=True, filterable="advanced" ), URLColumn( "Public URL" ), - grids.IndividualTagsColumn( "Tags", "tags", model.Page, model.PageTagAssociation, filterable="advanced", grid_name="PageListGrid" ), + grids.OwnerAnnotationColumn( "Annotation", key="annotation", model_class=model.Page, model_annotation_association_class=model.PageAnnotationAssociation, filterable="advanced" ), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.Page, model_tag_association_class=model.PageTagAssociation, filterable="advanced", grid_name="PageListGrid" ), grids.SharingStatusColumn( "Sharing", key="sharing", model_class=model.Page, filterable="advanced", sortable=False ), grids.GridColumn( "Created", key="create_time", format=time_ago ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), @@ -63,7 +64,7 @@ class PageAllPublishedGrid( grids.Grid ) grids.PublicURLColumn( "Title", key="title", model_class=model.Page, filterable="advanced" ), grids.OwnerAnnotationColumn( "Annotation", key="annotation", model_class=model.Page, model_annotation_association_class=model.PageAnnotationAssociation, filterable="advanced" ), grids.OwnerColumn( "Owner", key="username", model_class=model.User, filterable="advanced", sortable=False ), - grids.CommunityTagsColumn( "Community Tags", "tags", model.Page, model.PageTagAssociation, filterable="advanced", grid_name="PageAllPublishedGrid" ), + grids.CommunityTagsColumn( "Community Tags", key="tags", model_class=model.Page, model_tag_association_class=model.PageTagAssociation, filterable="advanced", grid_name="PageAllPublishedGrid" ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ) ] columns.append( @@ -107,7 +108,7 @@ class HistorySelectionGrid( ItemSelectio model_class = model.History columns = [ ItemSelectionGrid.NameColumn( "Name", key="name", model_class=model.History, filterable="advanced" ), - grids.IndividualTagsColumn( "Tags", "tags", model.History, model.HistoryTagAssociation, filterable="advanced"), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.History, model_tag_association_class=model.HistoryTagAssociation, filterable="advanced"), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), # Columns that are valid for filtering but are not visible. grids.DeletedColumn( "Deleted", key="deleted", visible=False, filterable="advanced" ), @@ -130,7 +131,7 @@ class HistoryDatasetAssociationSelection model_class = model.HistoryDatasetAssociation columns = [ ItemSelectionGrid.NameColumn( "Name", key="name", model_class=model.HistoryDatasetAssociation, filterable="advanced" ), - grids.IndividualTagsColumn( "Tags", "tags", model.HistoryDatasetAssociation, model.HistoryDatasetAssociationTagAssociation, filterable="advanced"), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.HistoryDatasetAssociation, model_tag_association_class=model.HistoryDatasetAssociationTagAssociation, filterable="advanced"), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), # Columns that are valid for filtering but are not visible. grids.DeletedColumn( "Deleted", key="deleted", visible=False, filterable="advanced" ), @@ -155,7 +156,7 @@ class WorkflowSelectionGrid( ItemSelecti model_class = model.StoredWorkflow columns = [ ItemSelectionGrid.NameColumn( "Name", key="name", model_class=model.StoredWorkflow, filterable="advanced" ), - grids.IndividualTagsColumn( "Tags", "tags", model.StoredWorkflow, model.StoredWorkflowTagAssociation, filterable="advanced"), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.StoredWorkflow, model_tag_association_class=model.StoredWorkflowTagAssociation, filterable="advanced"), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), # Columns that are valid for filtering but are not visible. grids.DeletedColumn( "Deleted", key="deleted", visible=False, filterable="advanced" ), @@ -175,7 +176,7 @@ class PageSelectionGrid( ItemSelectionGr model_class = model.Page columns = [ grids.TextColumn( "Title", key="title", model_class=model.Page, filterable="advanced" ), - grids.IndividualTagsColumn( "Tags", "tags", model.Page, model.PageTagAssociation, filterable="advanced"), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.Page, model_tag_association_class=model.PageTagAssociation, filterable="advanced"), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), # Columns that are valid for filtering but are not visible. grids.DeletedColumn( "Deleted", key="deleted", visible=False, filterable="advanced" ), @@ -196,7 +197,7 @@ class VisualizationSelectionGrid( ItemSe columns = [ grids.TextColumn( "Title", key="title", model_class=model.Visualization, filterable="advanced" ), grids.TextColumn( "Type", key="type", model_class=model.Visualization ), - grids.IndividualTagsColumn( "Tags", "tags", model.Visualization, model.VisualizationTagAssociation, filterable="advanced", grid_name="VisualizationListGrid" ), + grids.IndividualTagsColumn( "Tags", key="tags", model_class=model.Visualization, model_tag_association_class=model.VisualizationTagAssociation, filterable="advanced", grid_name="VisualizationListGrid" ), grids.SharingStatusColumn( "Sharing", key="sharing", model_class=model.Visualization, filterable="advanced", sortable=False ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago ), ] --- a/lib/galaxy/web/framework/helpers/grids.py +++ b/lib/galaxy/web/framework/helpers/grids.py @@ -140,15 +140,14 @@ class Grid( object ): sort_key = kwargs['sort'] elif base_sort_key: sort_key = base_sort_key - encoded_sort_key = sort_key if sort_key: if sort_key.startswith( "-" ): # Can't use lower() on timestamp or integer objects, so func.lower() is not used here... query = query.order_by( self.model_class.table.c.get( sort_key[1:] ).desc() ) else: - # See reason for not using lower() to do case-insensitive search. + # See reason for not using lower() to do case-insensitive sorting. query = query.order_by( self.model_class.table.c.get( sort_key ).asc() ) - extra_url_args['sort'] = encoded_sort_key + extra_url_args['sort'] = sort_key # There might be a current row current_item = self.get_current_item( trans, **kwargs ) # Process page number. @@ -222,7 +221,6 @@ class Grid( object ): default_filter_dict=self.default_filter, cur_filter_dict=cur_filter_dict, sort_key=sort_key, - encoded_sort_key=encoded_sort_key, current_item=current_item, ids = kwargs.get( 'id', [] ), url = url, @@ -260,10 +258,11 @@ class Grid( object ): return query class GridColumn( object ): - def __init__( self, label, key=None, model_class=None, method=None, format=None, link=None, attach_popup=False, visible=True, ncells=1, + def __init__( self, label, grid=None, key=None, model_class=None, method=None, format=None, link=None, attach_popup=False, visible=True, ncells=1, # Valid values for filterable are ['standard', 'advanced', None] filterable=None, sortable=True ): self.label = label + self.grid = grid self.key = key self.model_class = model_class self.method = method --- a/templates/grid_base.mako +++ b/templates/grid_base.mako @@ -255,7 +255,7 @@ } // Add sort argument to URL args. - url_args['sort'] = "${encoded_sort_key}"; + url_args['sort'] = "${sort_key}"; // Add async keyword to URL args. url_args['async'] = true;
participants (1)
-
commits-noreply@bitbucket.org