diff --git a/lib/galaxy/web/framework/helpers/grids.py b/lib/galaxy/web/framework/helpers/grids.py index 08f7603b2c4..6031898535b 100644 --- a/lib/galaxy/web/framework/helpers/grids.py +++ b/lib/galaxy/web/framework/helpers/grids.py @@ -777,6 +777,27 @@ class DeletedColumn(GridColumn): return query +class PurgedColumn(GridColumn): + """ Column that tracks and filters for items with purged attribute. """ + + def get_accepted_filters(self): + """ Returns a list of accepted filters for this column. """ + accepted_filter_labels_and_vals = {"nonpurged" : "False", "purged" : "True", "all": "All"} + accepted_filters = [] + for label, val in accepted_filter_labels_and_vals.items(): + args = {self.key: val} + accepted_filters.append(GridColumnFilter(label, args)) + return accepted_filters + + def filter(self, trans, user, query, column_filter): + """Modify query to filter self.model_class by state.""" + if column_filter == "All": + pass + elif column_filter in ["True", "False"]: + query = query.filter(self.model_class.purged == (column_filter == "True")) + return query + + class StateColumn(GridColumn): """ Column that tracks and filters for items with state attribute. diff --git a/lib/galaxy/webapps/galaxy/controllers/admin.py b/lib/galaxy/webapps/galaxy/controllers/admin.py index 800f9f6d5b0..a2dee924595 100644 --- a/lib/galaxy/webapps/galaxy/controllers/admin.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin.py @@ -130,7 +130,8 @@ class UserListGrid(grids.Grid): ActivatedColumn("Activated", attach_popup=False), APIKeyColumn("API Key", attach_popup=False), # Columns that are valid for filtering but are not visible. - grids.DeletedColumn("Deleted", key="deleted", visible=False, filterable="advanced") + grids.DeletedColumn("Deleted", key="deleted", visible=False, filterable="advanced"), + grids.PurgedColumn("Purged", key="purged", visible=False, filterable="advanced") ] columns.append(grids.MulticolFilterColumn("Search", cols_to_filter=[columns[0], columns[1]], @@ -170,6 +171,8 @@ class UserListGrid(grids.Grid): ] num_rows_per_page = 50 use_paging = True + default_filter = dict(purged="False") + use_default_filter = True def get_current_item(self, trans, **kwargs): return trans.user