Добавлено API для получения списка атрибутов и их значений; обновлены формы для работы с атрибутами через JavaScript

This commit is contained in:
2025-12-30 02:41:30 +03:00
parent f39ee5f15d
commit a3f2185714
6 changed files with 498 additions and 46 deletions

View File

@@ -13,7 +13,7 @@ from django.contrib.auth.decorators import login_required
from django.db import transaction
from user_roles.mixins import ManagerOwnerRequiredMixin
from ..models import ConfigurableProduct, ConfigurableProductOption, ProductKit, ConfigurableProductAttribute
from ..models import ConfigurableProduct, ConfigurableProductOption, ProductKit, ConfigurableProductAttribute, ProductAttribute
from ..forms import (
ConfigurableProductForm,
ConfigurableProductOptionFormSetCreate,
@@ -144,6 +144,9 @@ class ConfigurableProductCreateView(LoginRequiredMixin, ManagerOwnerRequiredMixi
is_temporary=False
).order_by('name')
# Справочник атрибутов для autocomplete
context['product_attributes'] = ProductAttribute.objects.prefetch_related('values').order_by('position', 'name')
return context
def form_valid(self, form):
@@ -420,6 +423,9 @@ class ConfigurableProductUpdateView(LoginRequiredMixin, ManagerOwnerRequiredMixi
is_temporary=False
).order_by('name')
# Справочник атрибутов для autocomplete
context['product_attributes'] = ProductAttribute.objects.prefetch_related('values').order_by('position', 'name')
return context
def form_valid(self, form):