From d856df9544574c6971788d970c3f5688720c87d9 Mon Sep 17 00:00:00 2001 From: spacenergy Date: Thu, 25 Feb 2016 10:04:14 +0600 Subject: [PATCH] auto --- batiskaf/templates/jinja2/product.jinja | 67 ++++++++++++++++++++++++- store/views.py | 10 ++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/batiskaf/templates/jinja2/product.jinja b/batiskaf/templates/jinja2/product.jinja index 226fe75..f5626b2 100644 --- a/batiskaf/templates/jinja2/product.jinja +++ b/batiskaf/templates/jinja2/product.jinja @@ -41,7 +41,10 @@ data-zoom-image='/static/{{ product.main_image().url }}'/> +
+

Доставка по Казахстану: от 2 до 12 дней, в зависимости от выбранного способа доставки.

+

{{ product.title }}

@@ -113,12 +116,74 @@
{{ product.description|linebreaks|safe }}
+ {% if ranee %} +
+

Ранее просмотренные товары

+ + + + +
+
+ {% for product in ranee %} +
+
+ {% set im = product.main_image()|thumbnail("420x420") %} + Купить {{ product.title }} +
+ +
+ {{ product.min_price() }} ₸ +
+ {% if product.in_stock() %} +
+ Товар + есть в наличии +
+ {% else %} +
+ Товара + нет в наличии +
+ {% endif %} +
+ {% if product.in_stock() %} + Добавить в корзину + {% else %} + Заказать + {% endif %} +
+
+
+
+ {% endfor %} +
+
+ + + + + + + {% endif %}

Отзывы о товаре {{ product.title }}


- +
    {% if product.feedback.all() %} {% for comment in product.feedback.all() %} diff --git a/store/views.py b/store/views.py index 7a50057..f7b0ed6 100644 --- a/store/views.py +++ b/store/views.py @@ -157,6 +157,12 @@ class ProductView(CategoryBaseView, DetailView): def get(self, request, *args, **kwargs): self.category = self._get_full_category(kwargs['categories']) retval = super(ProductView, self).get(request, args, kwargs) + ranee = request.session.get('ranee', []) + #import pdb;pdb.set_trace() + if kwargs['slug'] not in ranee: + ranee.append(kwargs['slug']) + request.session['ranee'] = ranee + return retval def get_context_data(self, **kwargs): @@ -164,6 +170,10 @@ class ProductView(CategoryBaseView, DetailView): retval['category'] = self.category retval['form'] = ProductFeedbackForm(self.request.POST or None) retval['updated'] = ProductsUpdate.objects.last() + ranee = self.request.session.get('ranee', []) + #import pdb;pdb.set_trace() + #ranee.pop(kwargs['object'].slug) + retval['ranee'] = Product.objects.filter(slug__in=ranee).exclude(pk = kwargs['object'].pk)[:4] return retval def post(self, request, *args, **kwargs):