summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
-rw-r--r--bitbake/lib/toaster/toastergui/widgets.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py
index d2ef5d3dba..0f103505b2 100644
--- a/bitbake/lib/toaster/toastergui/widgets.py
+++ b/bitbake/lib/toaster/toastergui/widgets.py
@@ -243,18 +243,23 @@ class ToasterTable(TemplateView):
243 raise Exception("Search fields aren't defined in the model %s" 243 raise Exception("Search fields aren't defined in the model %s"
244 % self.queryset.model) 244 % self.queryset.model)
245 245
246 search_queries = [] 246 search_queries = None
247 for st in search_term.split(" "): 247 for st in search_term.split(" "):
248 q_map = [Q(**{field + '__icontains': st}) 248 queries = None
249 for field in self.queryset.model.search_allowed_fields] 249 for field in self.queryset.model.search_allowed_fields:
250 250 query = Q(**{field + '__icontains': st})
251 search_queries.append(reduce(operator.or_, q_map)) 251 if queries:
252 252 queries |= query
253 search_queries = reduce(operator.and_, search_queries) 253 else:
254 queries = query
255
256 if search_queries:
257 search_queries &= queries
258 else:
259 search_queries = queries
254 260
255 self.queryset = self.queryset.filter(search_queries) 261 self.queryset = self.queryset.filter(search_queries)
256 262
257
258 def get_data(self, request, **kwargs): 263 def get_data(self, request, **kwargs):
259 """ 264 """
260 Returns the data for the page requested with the specified 265 Returns the data for the page requested with the specified