diff --git a/myproject/products/forms.py b/myproject/products/forms.py index 13993f8..7026d2b 100644 --- a/myproject/products/forms.py +++ b/myproject/products/forms.py @@ -98,7 +98,8 @@ class ProductForm(SKUUniqueMixin, forms.ModelForm): model = Product fields = [ 'name', 'sku', 'description', 'short_description', 'categories', - 'tags', 'base_unit', 'price', 'sale_price', 'status' + 'tags', 'base_unit', 'price', 'sale_price', 'status', + 'is_new', 'is_popular', 'is_special' ] labels = { 'name': 'Название', @@ -149,6 +150,13 @@ class ProductForm(SKUUniqueMixin, forms.ModelForm): self.fields['base_unit'].required = False self.fields['base_unit'].help_text = 'Базовая единица для учета товара на складе. На основе этой единицы можно создать единицы продажи.' + # Маркетинговые флаги (switch-стиль) + for flag_field in ['is_new', 'is_popular', 'is_special']: + self.fields[flag_field].widget.attrs.update({ + 'class': 'form-check-input', + 'role': 'switch' + }) + def clean_name(self): """Валидация уникальности имени для активных товаров""" name = self.cleaned_data.get('name') diff --git a/myproject/products/templates/products/product_detail.html b/myproject/products/templates/products/product_detail.html index 56928ee..00f3de8 100644 --- a/myproject/products/templates/products/product_detail.html +++ b/myproject/products/templates/products/product_detail.html @@ -338,6 +338,23 @@ {% endif %} + + Маркетинговые флаги: + + {% if product.is_new %} + Новинка + {% endif %} + {% if product.is_popular %} + Популярный + {% endif %} + {% if product.is_special %} + Спецпредложение + {% endif %} + {% if not product.is_new and not product.is_popular and not product.is_special %} + - + {% endif %} + + Дата создания: {{ product.created_at }} diff --git a/myproject/products/templates/products/product_form.html b/myproject/products/templates/products/product_form.html index 9100d3d..ea68cc0 100644 --- a/myproject/products/templates/products/product_form.html +++ b/myproject/products/templates/products/product_form.html @@ -530,6 +530,43 @@
+ +
+
Маркетинговые флаги
+

Отображаются на внешних площадках (Recommerce и др.)

+
+
+
+ {{ form.is_new }} + +
+ Товар отображается как новый +
+
+
+ {{ form.is_popular }} + +
+ Товар отображается как популярный +
+
+
+ {{ form.is_special }} + +
+ Акционный товар (+ автоматически при скидке) +
+
+
+ +
+ {% if object %}
diff --git a/myproject/products/templates/products/products_list.html b/myproject/products/templates/products/products_list.html index 6ce9f1c..9d02fab 100644 --- a/myproject/products/templates/products/products_list.html +++ b/myproject/products/templates/products/products_list.html @@ -246,6 +246,11 @@ {% else %} {{ item.name }} {% endif %} +
+ {% if item.is_new %}{% endif %} + {% if item.is_popular %}{% endif %} + {% if item.is_special %}{% endif %} +
{{ item.sku }}