cleanup code
This commit is contained in:
parent
5e5d2832cd
commit
9edd3fef18
|
|
@ -44,15 +44,16 @@ class ProductSimilarView(ProductListView):
|
|||
"""
|
||||
Return base product instance for a getting list of similar products.
|
||||
"""
|
||||
find_by = {
|
||||
'slug': self.kwargs.get('slug'),
|
||||
}
|
||||
|
||||
if isinstance(self.kwargs.get('type'), str):
|
||||
if not self.kwargs.get('type') in ProductType.INDEX_PLURAL_ONE:
|
||||
return None
|
||||
product_type = get_object_or_404(ProductType.objects.all(), index_name=ProductType.INDEX_PLURAL_ONE[self.kwargs.get('type')])
|
||||
product = get_object_or_404(Product.objects.all(),
|
||||
slug=self.kwargs.get('slug'), product_type=product_type)
|
||||
else:
|
||||
product = get_object_or_404(Product.objects.all(),
|
||||
slug=self.kwargs.get('slug'))
|
||||
find_by['product_type'] = get_object_or_404(ProductType.objects.all(), index_name=ProductType.INDEX_PLURAL_ONE[self.kwargs.get('type')])
|
||||
|
||||
product = get_object_or_404(Product.objects.all(), **find_by)
|
||||
return product
|
||||
|
||||
|
||||
|
|
@ -117,6 +118,6 @@ class SimilarListView(ProductSimilarView):
|
|||
base_product = self.get_base_object()
|
||||
|
||||
if base_product:
|
||||
return qs.has_location().similar(base_product)[:settings.QUERY_OUTPUT_OBJECTS]
|
||||
return qs.similar(base_product)[:settings.QUERY_OUTPUT_OBJECTS]
|
||||
else:
|
||||
return qs.none()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user