Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Align existing code with new backend
Jakub Draganekb0e7f72a83be
diff --git a/saleor/dashboard/search/forms.py b/saleor/dashboard/search/forms.pyindex 331ce69b82..b72f487a82 100644--- a/saleor/dashboard/search/forms.py+++ b/saleor/dashboard/search/forms.py@@ -1,5 +1,5 @@from ...search.forms import SearchForm-from .backends import newelastic+from ...search.backends import newelasticclass DashboardSearchForm(SearchForm):diff --git a/saleor/search/backends/newelastic.py b/saleor/search/backends/newelastic.pyindex 2dc4b7e20d..e3497e0b51 100644--- a/saleor/search/backends/newelastic.py+++ b/saleor/search/backends/newelastic.py@@ -30,15 +30,8 @@ class SearchBackend(object):rebuilder_class = Noneclient = None- def __init__(self, params):- self._init_client(params)-- @classmethod- def _init_client(cls, params):- if cls.client is None:- cls.client = Elasticsearch(hosts=_get_es_hosts(params))-- def search(self, query, model_or_queryset):+ @staticmethod+ def search(query, model_or_queryset):qs = model_or_queryset# TODO: remove this ugly type incoherence of old search apiif not isinstance(model_or_queryset, QuerySet):@@ -53,5 +46,4 @@ def search_products(phrase):.query(query).source(False).filter('term', is_published=True))- #.using(SearchBackend.client)) # TODO: use defaultreturn [hit.meta.id for hit in search.execute()]diff --git a/saleor/search/forms.py b/saleor/search/forms.pyindex 670da51773..f06620396a 100644--- a/saleor/search/forms.py+++ b/saleor/search/forms.py@@ -8,7 +8,6 @@ class SearchForm(forms.Form):label=pgettext('Search form label', 'Query'), required=True)def search(self, model_or_queryset):- query = self.cleaned_data['q']- results = newelastic.SearchBackend.search(- query, model_or_queryset=model_or_queryset)+ results = newelastic.SearchBackend.search(self.cleaned_data['q'],+ model_or_queryset)return resultsdiff --git a/tests/test_search.py b/tests/test_search.pyindex 887d9a2d65..b1471b616c 100644--- a/tests/test_search.py+++ b/tests/test_search.py@@ -1,4 +1,3 @@-from __future__ import unicode_literalsfrom saleor.product.models import Productfrom django.core.urlresolvers import reverse