Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Sort imports. Use transaction.atomic decorator
Artur Smęt9a50bf93101f
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 81a7f90f2a..5f468f896a 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -2,11 +2,11 @@ from __future__ import unicode_literalsfrom django import formsfrom django.db import transaction-from django.forms.models import inlineformset_factory, ModelChoiceIterator+from django.forms.models import ModelChoiceIterator, inlineformset_factoryfrom django.utils.translation import pgettext_lazy-from ...product.models import (ProductImage, Stock, ProductVariant, Product,- ProductAttribute, AttributeChoiceValue,+from ...product.models import (AttributeChoiceValue, Product, ProductAttribute,+ ProductImage, ProductVariant, Stock,VariantImage)from .widgets import ImagePreviewWidget@@ -151,15 +151,15 @@ class ProductImageForm(forms.ModelForm):if self.instance.image:self.fields['image'].widget = ImagePreviewWidget()+ @transaction.atomicdef save_variant_images(self, instance):variant_images = []# Clean up old mapping- with transaction.atomic():- instance.variant_images.all().delete()- for variant in self.cleaned_data['variants']:- variant_images.append(- VariantImage(variant=variant, image=instance))- VariantImage.objects.bulk_create(variant_images)+ instance.variant_images.all().delete()+ for variant in self.cleaned_data['variants']:+ variant_images.append(+ VariantImage(variant=variant, image=instance))+ VariantImage.objects.bulk_create(variant_images)def save(self, commit=True):instance = super(ProductImageForm, self).save(commit=commit)