feat: websockets
CI / test (push) Successful in 1m56s
CI / build (push) Successful in 48s

This commit is contained in:
2026-07-31 14:27:50 +02:00
parent 125c9dd186
commit 393b39cacd
13 changed files with 626 additions and 2 deletions
+21
View File
@@ -350,11 +350,32 @@ class ProductVariantCreateView(ProductVariantAttributesContextMixin, BackofficeC
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
product = self.get_product()
context.setdefault('price_form', ProductInitialPriceForm())
context.update(
{'title': f'Añadir variante a {product.name}', 'cancel_url': reverse_lazy('backoffice:product_detail', args=[product.pk])}
)
return context
def form_valid(self, form):
# El precio es opcional y se crea en el mismo envío que la variante,
# igual que en ProductCreateView (ver ProductInitialPriceForm).
price_form = ProductInitialPriceForm(self.request.POST)
if not price_form.is_valid():
return self.render_to_response(self.get_context_data(form=form, price_form=price_form))
response = super().form_valid(form)
if price_form.cleaned_data.get('price') is not None:
ProductPrice.objects.create(
variant=self.object,
price=price_form.get_price_without_tax(),
tax=price_form.cleaned_data['tax'],
current=True,
)
return response
def get_success_url(self):
return reverse_lazy('backoffice:product_detail', args=[self.object.product_id])