From 0ed3481f1bee602a2178fca7618da8cfa61a5210 Mon Sep 17 00:00:00 2001 From: spacenergy Date: Mon, 4 Apr 2016 11:11:31 +0600 Subject: [PATCH] no message --- .../includes/category_product_thumb.jinja | 6 + batiskaf/templates/jinja2/index.jinja | 5 + batiskaf/templates/jinja2/product.jinja | 123 ++++++++++-------- main/views.py | 2 +- store/models.py | 6 + 5 files changed, 89 insertions(+), 53 deletions(-) diff --git a/batiskaf/templates/jinja2/includes/category_product_thumb.jinja b/batiskaf/templates/jinja2/includes/category_product_thumb.jinja index 1cee604..d347073 100644 --- a/batiskaf/templates/jinja2/includes/category_product_thumb.jinja +++ b/batiskaf/templates/jinja2/includes/category_product_thumb.jinja @@ -40,6 +40,12 @@ href="/store/cart/add/?pk={{ product.variations.filter(in_stock__gt=0).order_by('price').first().pk }}&count=1&next={{ request.get_full_path()|urlencode }}"> Добавить в корзину + {% elif product.delivery_date() %} + Ожидается {{ product.delivery_date() }} + {% else %} Добавить в корзину + {% elif product.delivery_date() %} + Ожидается {{ product.delivery_date() }} {% else %} -->
-

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

+

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

@@ -94,10 +97,19 @@
- Товара нет в наличии


-
Заказать + {% if product.delivery_date() %} + Ожидается {{ product.delivery_date() }} + {% else %} + + Товара нет в наличии


+ Заказать + {% endif %}

Цены и наличие товара актуальны @@ -117,67 +129,74 @@ {{ product.description|linebreaks|safe }}
{% if product.video %} -
-
Видео обзор
-
- -

- {%endif%} +
+
Видео обзор
+
+ +

+ {% endif %} {% if ranee %} -
-

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

+
+

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

-
-
- {% for product in ranee %} -
-
- {% set im = product.main_image()|thumbnail("420x420") %} - Купить {{ product.title }} -
- -
- {{ product.min_price(request.user) }} ₸ -
- {% if product.in_stock() %} -
- Товар - есть в наличии +
+
+ {% for product in ranee %} +
+
+ {% set im = product.main_image()|thumbnail("420x420") %} + Купить {{ product.title }} +
+ - {% else %} -
- Товара - нет в наличии +
+ {{ product.min_price(request.user) }} ₸
- {% endif %} -
{% if product.in_stock() %} - Добавить в корзину +
+ Товар + есть в наличии +
{% else %} - Заказать +
+ Товара + нет в наличии +
{% endif %} +
+ {% if product.in_stock() %} + Добавить в корзину + {% elif product.delivery_date() %} + Ожидается {{ product.delivery_date() }} + + {% else %} + Заказать + {% endif %} +
-
- {% endfor %} + {% endfor %} +
-
diff --git a/main/views.py b/main/views.py index cbe10d5..01fa040 100644 --- a/main/views.py +++ b/main/views.py @@ -109,7 +109,7 @@ def temp_count_update(request, article): product.delivery_date = delivery_date product.save() if delivery_date is None: - product.delivery_date = '' + product.delivery_date = None product.save() else: retval['error_code'] = 1 diff --git a/store/models.py b/store/models.py index c47b4d4..5f1f6aa 100644 --- a/store/models.py +++ b/store/models.py @@ -203,6 +203,12 @@ class Product(models.Model): def in_stock(self): return self.variations.filter(in_stock__gt=0).count() + def delivery_date(self): + try: + return self.variations.filter(delivery_date__isnull=False)[0].delivery_date + except: + return None + def min_price_variation(self): min_v = None for v in self.variations.all():