Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

rf#208 Remove excess arguments from get_category_descendants. #338

Merged
merged 2 commits into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 11 additions & 5 deletions stroyprombeton/views/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ 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 = 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:
term = term.strip()
lookups = [
'name__icontains',
'code__icontains',
Expand Down Expand Up @@ -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 {
Expand Down