From f4ec1bac831f6df572cb62fe90798e996c230696 Mon Sep 17 00:00:00 2001 From: cat-bro Date: Tue, 4 May 2021 18:47:24 +1000 Subject: [PATCH 1/2] update legacy_framework.grids.StateColumn: model_class.states is Enum now instead of Bunch --- lib/galaxy/web/legacy_framework/grids.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/galaxy/web/legacy_framework/grids.py b/lib/galaxy/web/legacy_framework/grids.py index f1bf7c1232c..d0a0a0c1f4a 100644 --- a/lib/galaxy/web/legacy_framework/grids.py +++ b/lib/galaxy/web/legacy_framework/grids.py @@ -390,9 +390,6 @@ class DeletedColumn(GridColumn): class StateColumn(GridColumn): """ Column that tracks and filters for items with state attribute. - - IMPORTANT NOTE: self.model_class must have a states Bunch or dict if - this column type is used in the grid. """ def get_value(self, trans, grid, item): @@ -402,7 +399,7 @@ class StateColumn(GridColumn): """Modify query to filter self.model_class by state.""" if column_filter == "All": pass - elif column_filter in [v for k, v in self.model_class.states.items()]: + elif column_filter in [state.value for state in self.model_class.states]: query = query.filter(self.model_class.state == column_filter) return query @@ -410,9 +407,9 @@ class StateColumn(GridColumn): """Returns a list of accepted filters for this column.""" all = GridColumnFilter('all', {self.key: 'All'}) accepted_filters = [all] - for v in self.model_class.states.values(): - args = {self.key: v} - accepted_filters.append(GridColumnFilter(v, args)) + for state in self.model_class.states: + args = {self.key: state.value} + accepted_filters.append(GridColumnFilter(state.value, args)) return accepted_filters From 4f8503be2910a6e8997312db8d3c8b130866374e Mon Sep 17 00:00:00 2001 From: cat-bro Date: Tue, 4 May 2021 22:13:01 +1000 Subject: [PATCH 2/2] Update lib/galaxy/web/legacy_framework/grids.py Co-authored-by: Marius van den Beek --- lib/galaxy/web/legacy_framework/grids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/web/legacy_framework/grids.py b/lib/galaxy/web/legacy_framework/grids.py index d0a0a0c1f4a..da77a2b27ee 100644 --- a/lib/galaxy/web/legacy_framework/grids.py +++ b/lib/galaxy/web/legacy_framework/grids.py @@ -399,7 +399,7 @@ class StateColumn(GridColumn): """Modify query to filter self.model_class by state.""" if column_filter == "All": pass - elif column_filter in [state.value for state in self.model_class.states]: + elif column_filter in list(self.model_class.states): query = query.filter(self.model_class.state == column_filter) return query