Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add 'is_published' validation in product mutations and fix typo in dashboard validation
IKarbowiak001d8a489381
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 96030f69af..9257ecfe74 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -367,10 +367,10 @@ class ProductForm(MoneyModelForm, AttributesMixin):return seo_descriptiondef clean_is_published(self):- is_published = self.cleaned_data["is_published"]- category = self.data["category"]+ is_published = self.cleaned_data.get("is_published")+ category = self.data.get("category")if not category and is_published:- raise ValidationError("You must add cateogry to publish product")+ raise ValidationError("You must select a category to be able to publish")return is_publisheddef save(self, commit=True):diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 5164e5b430..e5a090767b 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -807,6 +807,17 @@ class ProductCreate(ModelMutation):except ValidationError as exc:raise ValidationError({"attributes": exc})+ is_published = cleaned_input.get("is_published")+ category = cleaned_input.get("category")+ if not category and is_published:+ raise ValidationError(+ {+ "isPublished": ValidationError(+ "You must select a category to be able to publish"+ )+ }+ )+clean_seo_fields(cleaned_input)cls.clean_sku(product_type, cleaned_input)return cleaned_input