def get_queryset(self): self.kwargs['branch'] = 'oe-classic' query_string = self.request.GET.get('q', '') cover_status = self.request.GET.get('cover_status', None) cover_verified = self.request.GET.get('cover_verified', None) category = self.request.GET.get('category', None) init_qs = ClassicRecipe.objects.filter(layerbranch__branch__name='oe-classic') if cover_status: if cover_status == '!': init_qs = init_qs.filter(cover_status__in=['U', 'N']) else: init_qs = init_qs.filter(cover_status=cover_status) if cover_verified: init_qs = init_qs.filter(cover_verified=(cover_verified=='1')) if category: init_qs = init_qs.filter(classic_category__icontains=category) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['pn', 'summary', 'description', 'filename']) qs = init_qs.filter(entry_query).order_by('pn', 'layerbranch__layer') else: if 'q' in self.request.GET: qs = init_qs.order_by('pn', 'layerbranch__layer') else: # It's a bit too slow to return all records by default, and most people # won't actually want that (if they do they can just hit the search button # with no query string) return Recipe.objects.none() return qs
def get_queryset(self): _check_url_branch(self.kwargs) query_string = self.request.GET.get('q', '') init_qs = Machine.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name', 'description']) return init_qs.filter(entry_query).order_by('name', 'layerbranch__layer') else: if 'q' in self.request.GET: return init_qs.order_by('name', 'layerbranch__layer') else: # Be consistent with RecipeSearchView return Machine.objects.none()
def get_queryset(self): _check_url_branch(self.kwargs) query_string = self.request.GET.get('q', '') init_qs = Recipe.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['pn', 'summary', 'description', 'filename']) qs = init_qs.filter(entry_query).order_by('pn', 'layerbranch__layer') else: if 'q' in self.request.GET: qs = init_qs.order_by('pn', 'layerbranch__layer') else: # It's a bit too slow to return all records by default, and most people # won't actually want that (if they do they can just hit the search button # with no query string) return Recipe.objects.none() return recipes_preferred_count(qs)