From 2e9097a4eea1560c8a218920058dedcf6b40804d Mon Sep 17 00:00:00 2001 From: guerler Date: Fri, 1 Dec 2023 11:30:57 +0300 Subject: [PATCH] Adjust user grids default query, either filter on deleted or not deleted users --- .../webapps/galaxy/controllers/admin.py | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/admin.py b/lib/galaxy/webapps/galaxy/controllers/admin.py index edbdb722e15f..ade0de78b7ca 100644 --- a/lib/galaxy/webapps/galaxy/controllers/admin.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin.py @@ -131,32 +131,31 @@ def apply_query_filter(self, query, **kwargs): } search_query = kwargs.get("search") parsed_search = parse_filters_structured(search_query, INDEX_SEARCH_FILTERS) - if len(parsed_search.terms) == 0: - query = query.filter(self.model_class.deleted == false()) - else: - for term in parsed_search.terms: - if isinstance(term, FilteredTerm): - key = term.filter - q = term.text - if key == "email": - query = query.filter(text_column_filter(self.model_class.email, term)) - elif key == "username": - query = query.filter(text_column_filter(self.model_class.username, term)) - elif key == "is": - if q == "deleted": - query = query.filter(self.model_class.deleted == true()) - elif q == "purged": - query = query.filter(self.model_class.purged == true()) - elif isinstance(term, RawTextTerm): - query = query.filter( - raw_text_column_filter( - [ - self.model_class.email, - self.model_class.username, - ], - term, - ) + deleted = False + for term in parsed_search.terms: + if isinstance(term, FilteredTerm): + key = term.filter + q = term.text + if key == "email": + query = query.filter(text_column_filter(self.model_class.email, term)) + elif key == "username": + query = query.filter(text_column_filter(self.model_class.username, term)) + elif key == "is": + if q == "deleted": + deleted = True + elif q == "purged": + query = query.filter(self.model_class.purged == true()) + elif isinstance(term, RawTextTerm): + query = query.filter( + raw_text_column_filter( + [ + self.model_class.email, + self.model_class.username, + ], + term, ) + ) + query = query.filter(self.model_class.deleted == (true() if deleted else false())) return query