From ab8b7accfd46baf7d7c3a6a93a9763b29bfe068a Mon Sep 17 00:00:00 2001 From: Artemiy Rodionov Date: Thu, 15 Nov 2018 13:29:53 +0300 Subject: [PATCH 1/2] Remove excess arguments from get_category_descendants. Bump the refarm's version Bump rf version --- requirements.txt | 2 +- stroyprombeton/views/catalog.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index f424c75e..8d52d55f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,4 @@ Unidecode==1.0.22 ua-parser==0.8.0 user-agents==1.1.0 https://github.com/selwin/django-user_agents/archive/master.zip -https://github.com/fidals/refarm-site/archive/0.4.15.zip +https://github.com/fidals/refarm-site/archive/0.4.16.zip diff --git a/stroyprombeton/views/catalog.py b/stroyprombeton/views/catalog.py index 7f3b073c..9320c462 100644 --- a/stroyprombeton/views/catalog.py +++ b/stroyprombeton/views/catalog.py @@ -27,8 +27,11 @@ def fetch_products(request): term = term.strip() category = models.Category.objects.get(id=category_id) - products = models.Product.objects.active().get_category_descendants( - category, ordering=settings.PRODUCTS_ORDERING + products = ( + models.Product.objects + .active() + .get_category_descendants(category) + .order_by(*settings.PRODUCTS_ORDERING) ) if filtered == 'true' and term: @@ -211,8 +214,11 @@ def get_context_data(self, **kwargs): context = super(ProductPDF, self).get_context_data(**kwargs) category = context[self.context_object_name] - products = models.Product.objects.active().get_category_descendants( - category, ordering=settings.PRODUCTS_ORDERING + products = ( + models.Product.objects + .active() + .get_category_descendants(category) + .order_by(*settings.PRODUCTS_ORDERING) ) return { From 3618b6f95f47d5afb0804e609d876b252ef2115f Mon Sep 17 00:00:00 2001 From: Artemiy Rodionov Date: Sun, 18 Nov 2018 15:55:02 +0300 Subject: [PATCH 2/2] Fix NoneType.trim(..) case --- stroyprombeton/views/catalog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stroyprombeton/views/catalog.py b/stroyprombeton/views/catalog.py index 9320c462..9ea2156d 100644 --- a/stroyprombeton/views/catalog.py +++ b/stroyprombeton/views/catalog.py @@ -24,7 +24,6 @@ def fetch_products(request): category_id, term, offset, limit, filtered = get_keys_from_post( request, 'categoryId', 'term', 'offset', 'limit', 'filtered', ) - term = term.strip() category = models.Category.objects.get(id=category_id) products = ( @@ -35,6 +34,7 @@ def fetch_products(request): ) if filtered == 'true' and term: + term = term.strip() lookups = [ 'name__icontains', 'code__icontains',