Skip to content

Commit

Permalink
Adjust user grids default query, either filter on deleted or not dele…
Browse files Browse the repository at this point in the history
…ted users
  • Loading branch information
guerler committed Dec 1, 2023
1 parent e75a6b6 commit 2e9097a
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions lib/galaxy/webapps/galaxy/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 2e9097a

Please sign in to comment.