Exemple #1
0
 def get_context_data(self, **kwargs):
     context = super(CatalogueView, self).get_context_data()
     context.update(self.get_meta_tokens())
     context['recently_viewed_products'] = history.get(self.request)
     context['filter_form'] = self.form
     context['paginate_form'] = self.paginate_form
     if hasattr(self, 'filter_descr'):
         context['filter_descr'] = self.filter_descr
     if hasattr(self, 'current_sort'):
         context['current_sort'] = self.current_sort
     if hasattr(self, 'current_path'):
         context['current_path'] = self.current_path
     if hasattr(self, 'basket_product_ids'):
         context['basket_product_ids'] = self.basket_product_ids
     context['filter_reset_url'] = self.request.path
     if hasattr(self, 'category'):
         context['category'] = self.category
         if self.category:
             context['filter_reset_url'] = self.category.get_absolute_url()
     price_range = [
         x.price
         for x in SearchQuerySet().models(Product).filter(site=self.site.pk)
         if x.price is not None
     ]
     try:
         context['max_price'] = int(max(price_range))
         context['price_range_min'] = int(
             self.request.GET.get('price_range_min'))
         context['price_range_max'] = int(
             self.request.GET.get('price_range_max'))
     except (ValueError, TypeError):
         pass
     return context
Exemple #2
0
def recently_viewed_products(context):
    """
    Inclusion tag listing the most recently viewed products
    """
    request = context['request']
    products = history.get(request)
    return {'products': products, 'request': request}
def recently_viewed_products(context):
    """
    Inclusion tag listing the most recently viewed products
    """
    request = context['request']
    products = history.get(request)
    return {'products': products,
            'request': request}
Exemple #4
0
def recently_viewed_products(context, current_product=None):
    """
    Inclusion tag listing the most recently viewed products
    """
    request = context['request']
    products = history.get(request)
    if current_product:
        products = [p for p in products if p != current_product]
    return {'products': products, 'request': request}
def recently_viewed_products(context, current_product=None):
    """
    Inclusion tag listing the most recently viewed products
    """
    request = context['request']
    products = history.get(request)
    if current_product:
        products = [p for p in products if p != current_product]
    return {'products': products,
            'request': request}
def recently_viewed_products(context):
    """
    Inclusion tag listing the most recently viewed products
    """
    print('******OVERRIDEN*************')
    safas
    request = context['request']
    products = history.get(request)
    return {'products': products,
            'request': request}
Exemple #7
0
 def render(self, context, instance, placeholder):
     request = context['request']
     products = history.get(request)
     if instance.limit > 0:
         products = products[:instance.limit]
     context.update({
         'products': products,
         'request': request,
         'instance': instance
     })
     return context
Exemple #8
0
 def get_context_data(self, **kwargs):
     ctx = {}
     ctx['summary'] = _("All products")
     search_context = self.search_handler.get_search_context_data(
         self.context_object_name)
     ctx.update(search_context)
     
     hotproduct = get_list_or_404(Product.objects.order_by('-date_updated'),hot_deals=True,is_on_shelves = True)[:7]
     ctx['hotproduct'] = hotproduct
     
     history_products = history.get(self.request)
     ctx['history_products'] = history_products
     
     category_list = Category.objects.filter(depth=1).order_by('id')[:10]
     ctx['category_list'] =category_list
     
     return ctx
Exemple #9
0
 def get_context_data(self, **kwargs):
     context = super(ProductDetailView, self).get_context_data()
     current_product = self.get_object()
     products = history.get(self.request)
     if current_product:
         products = [p for p in products if p != current_product]
     context['recently_viewed_products'] = products
     similar_products = current_product.get_similar_products()
     products_in_basket = [
         line.product for line in self.request.basket.lines.all()
     ]
     context['already_in_basket'] = current_product in products_in_basket
     context['similar_products'] = similar_products
     context['delivery_text'] = SiteConfig.objects.get(
         site=self.request.site).delivery_text
     context.update(self.get_meta_tokens())
     return context
Exemple #10
0
    def get_context_data(self, **kwargs):
        ctx = {}
        ctx['summary'] = _("All products")
        search_context = self.search_handler.get_search_context_data(
            self.context_object_name)
        ctx.update(search_context)

        hotproduct = get_list_or_404(Product.objects.order_by('-date_updated'),
                                     hot_deals=True,
                                     is_on_shelves=True)[:7]
        ctx['hotproduct'] = hotproduct

        history_products = history.get(self.request)
        ctx['history_products'] = history_products

        category_list = Category.objects.filter(depth=1).order_by('id')[:10]
        ctx['category_list'] = category_list

        return ctx
 def test_starts_with_empty_list(self):
     products = history.get(self.request)
     self.assertEqual([], products)
 def test_starts_with_empty_list(self):
     products = history.get(self.request)
     self.assertEqual([], products)
Exemple #13
0
 def render_to_response(self, context, **response_kwargs):
     obj = self.get_object()
     recent_products = [p for p in history.get(self.request) if p != obj]
     obj.change_similar_products(recent_products)
     return super(ProductDetailView,
                  self).render_to_response(context, **response_kwargs)