feat: Add SKU field to ProductKit form for kit creation
- Added 'sku' field to ProductKitForm meta fields list - Added SKU label in form labels - Added SKU widget styling in __init__ method with helpful placeholder - Updated productkit_form.html template to display SKU field after name, before description - Updated form field filtering to exclude 'sku' from dynamic loop to prevent duplication 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -82,11 +82,12 @@ class ProductKitForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = ProductKit
|
||||
fields = [
|
||||
'name', 'description', 'categories',
|
||||
'name', 'sku', 'description', 'categories',
|
||||
'tags', 'pricing_method', 'fixed_price', 'markup_percent', 'markup_amount', 'is_active'
|
||||
]
|
||||
labels = {
|
||||
'name': 'Название',
|
||||
'sku': 'Артикул',
|
||||
'description': 'Описание',
|
||||
'categories': 'Категории',
|
||||
'tags': 'Теги',
|
||||
@@ -104,6 +105,10 @@ class ProductKitForm(forms.ModelForm):
|
||||
'class': 'form-control',
|
||||
'placeholder': 'Введите название комплекта'
|
||||
})
|
||||
self.fields['sku'].widget.attrs.update({
|
||||
'class': 'form-control',
|
||||
'placeholder': 'Артикул (необязательно, будет сгенерирован автоматически)'
|
||||
})
|
||||
self.fields['description'].widget.attrs.update({
|
||||
'class': 'form-control',
|
||||
'rows': 3
|
||||
|
||||
@@ -140,6 +140,18 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Артикул -->
|
||||
<div class="mb-3">
|
||||
{{ form.sku.label_tag }}
|
||||
{{ form.sku }}
|
||||
{% if form.sku.help_text %}
|
||||
<small class="form-text text-muted">{{ form.sku.help_text }}</small>
|
||||
{% endif %}
|
||||
{% if form.sku.errors %}
|
||||
<div class="text-danger">{{ form.sku.errors }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Категория -->
|
||||
<div class="mb-3">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
@@ -175,7 +187,7 @@
|
||||
</div>
|
||||
|
||||
{% for field in form %}
|
||||
{% if field.name not in 'name,categories,description,tags' %}
|
||||
{% if field.name not in 'name,sku,categories,description,tags' %}
|
||||
{% if field.name == 'fixed_price' %}
|
||||
<!-- Alert для неактивного поля fixed_price -->
|
||||
<div id="fixed-price-alert" class="alert alert-warning d-none mb-3" role="alert">
|
||||
|
||||
Reference in New Issue
Block a user