From 7506fee20ad0657ae2c68eac62303a27daa29543 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Sun, 2 Nov 2025 21:08:41 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=BF=D1=80=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D1=87=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=B7=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BF=D0=BB=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Удалено ненужное поле 'notes' из формы создания/редактирования комплектов: - Удалено из модели KitItem - Удалено из формы KitItemForm - Удалено из template kititem_formset.html - Удалено из formset'ов KitItemFormSetCreate и KitItemFormSetUpdate - Создана миграция БД для удаления поля из базы данных Теперь каждый товар в комплекте отображается с 4 полями: - Товар (или Группа вариантов) - Количество - Кнопка удаления - ID (скрытое) 🤖 Generated with Claude Code Co-Authored-By: Claude --- myproject/products/forms.py | 10 ++++------ .../migrations/0005_remove_kititem_notes.py | 17 +++++++++++++++++ myproject/products/models/kits.py | 5 ----- .../products/includes/kititem_formset.html | 9 --------- 4 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 myproject/products/migrations/0005_remove_kititem_notes.py diff --git a/myproject/products/forms.py b/myproject/products/forms.py index c28e70e..a2b0aa3 100644 --- a/myproject/products/forms.py +++ b/myproject/products/forms.py @@ -166,18 +166,16 @@ class KitItemForm(forms.ModelForm): """ class Meta: model = KitItem - fields = ['product', 'variant_group', 'quantity', 'notes'] + fields = ['product', 'variant_group', 'quantity'] labels = { 'product': 'Конкретный товар', 'variant_group': 'Группа вариантов', - 'quantity': 'Количество', - 'notes': 'Примечание' + 'quantity': 'Количество' } widgets = { 'product': forms.Select(attrs={'class': 'form-control'}), 'variant_group': forms.Select(attrs={'class': 'form-control'}), 'quantity': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.001', 'min': '0'}), - 'notes': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Опциональное примечание'}), } def __init__(self, *args, **kwargs): @@ -254,7 +252,7 @@ KitItemFormSetCreate = inlineformset_factory( KitItem, form=KitItemForm, formset=BaseKitItemFormSet, - fields=['id', 'product', 'variant_group', 'quantity', 'notes'], + fields=['id', 'product', 'variant_group', 'quantity'], extra=1, # Показать 1 пустую форму для первого компонента can_delete=True, # Разрешить удаление компонентов min_num=0, # Минимум 0 компонентов (можно создать пустой комплект) @@ -268,7 +266,7 @@ KitItemFormSetUpdate = inlineformset_factory( KitItem, form=KitItemForm, formset=BaseKitItemFormSet, - fields=['id', 'product', 'variant_group', 'quantity', 'notes'], + fields=['id', 'product', 'variant_group', 'quantity'], extra=0, # НЕ показывать пустые формы при редактировании can_delete=True, # Разрешить удаление компонентов min_num=0, # Минимум 0 компонентов diff --git a/myproject/products/migrations/0005_remove_kititem_notes.py b/myproject/products/migrations/0005_remove_kititem_notes.py new file mode 100644 index 0000000..27e19fa --- /dev/null +++ b/myproject/products/migrations/0005_remove_kititem_notes.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.10 on 2025-11-02 18:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('products', '0004_add_kit_price_adjustment_fields'), + ] + + operations = [ + migrations.RemoveField( + model_name='kititem', + name='notes', + ), + ] diff --git a/myproject/products/models/kits.py b/myproject/products/models/kits.py index d445e27..8d75885 100644 --- a/myproject/products/models/kits.py +++ b/myproject/products/models/kits.py @@ -216,11 +216,6 @@ class KitItem(models.Model): verbose_name="Группа вариантов" ) quantity = models.DecimalField(max_digits=10, decimal_places=3, null=True, blank=True, verbose_name="Количество") - notes = models.CharField( - max_length=200, - blank=True, - verbose_name="Примечание" - ) class Meta: verbose_name = "Компонент комплекта" diff --git a/myproject/products/templates/products/includes/kititem_formset.html b/myproject/products/templates/products/includes/kititem_formset.html index 099547d..7ec0fb8 100644 --- a/myproject/products/templates/products/includes/kititem_formset.html +++ b/myproject/products/templates/products/includes/kititem_formset.html @@ -68,15 +68,6 @@ {% endif %} - - {% if kititem_form.notes %} -
-
- - {{ kititem_form.notes }} -
-
- {% endif %} {% endfor %}