Beispiel #1
0
    def search_products(self, q):
        """
        Search for products based on given query q.
        """
        products = self.get_products().filter(draft=False)

        if settings.SHOP_MULTIPLE_CATEGORIES:
            products = products.filter(
                categories__enabled=True
            ).exclude(
                categories=None
            ).distinct()
        else:
            products = products.filter(
                category_id__isnull=False,
                category__enabled=True
            )

        return fts_query(products, 'fts_index', q)
Beispiel #2
0
 def test_fts_query_should_ignore_brackets(self):
     parts = fts_query(TestFTSPart.objects.all(), 'fts_index', '(Test)')
     self.assertEqual(parts.count(), 1)
Beispiel #3
0
 def test_fts_query_not_matching(self):
     parts = fts_query(TestFTSPart.objects.all(), 'fts_index',
                       'Does Not Exist')
     self.assertEqual(parts.count(), 0)
Beispiel #4
0
 def test_fts_query_matching_alt_attr(self):
     parts = fts_query(TestFTSPart.objects.all(),
                       'fts_index',
                       '123',
                       alt_attr='partno')
     self.assertEqual(parts.count(), 1)