Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rf#208 Remove an excess argument from get_category_descendants #633

Merged
merged 2 commits into from
Nov 26, 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 @@ -23,4 +23,4 @@ ua-parser==0.8.0
user-agents==1.1.0
sorl-thumbnail==12.4a1
https://github.com/selwin/django-user_agents/archive/master.zip
https://github.com/fidals/refarm-site/archive/0.4.14.zip
https://github.com/fidals/refarm-site/archive/0.4.16.zip
2 changes: 1 addition & 1 deletion shopelectro/tests/tests_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def test_load_more_after_filtering(self):
self.load_more_products()
new_product_cards = len(self.browser.find_elements_by_class_name('product-card'))

self.assertEqual(new_product_cards, 50)
self.assertEqual(new_product_cards, 96)


class ProductPage(helpers.SeleniumTestCase):
Expand Down
10 changes: 7 additions & 3 deletions shopelectro/views/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ def load_more(request, category_slug, offset=0, limit=0, sorting=0, tags=None):
category = get_object_or_404(models.CategoryPage, slug=category_slug).model
sorting_option = context.SortingOption(index=int(sorting))

all_products = models.Product.objects.active().get_category_descendants(
category, ordering=(sorting_option.directed_field,)
all_products = (
models.Product.objects
.active()
.get_category_descendants(category)
.order_by(sorting_option.directed_field)
)

if tags:
Expand All @@ -225,7 +228,8 @@ def load_more(request, category_slug, offset=0, limit=0, sorting=0, tags=None):
.filter(tags__in=tag_entities)
# Use distinct because filtering by QuerySet tags,
# that related with products by many-to-many relation.
.distinct(sorting_option.field)
# Add `id` because `sorting_option.directed_field` maybe not uniq.
.distinct('id', sorting_option.directed_field)
)

paginated = context.PaginatorLinks(
Expand Down