Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Generate category slug if not provided
Marcin Gębala76011bd4a1c4
diff --git a/saleor/graphql/product/mutations.py b/saleor/graphql/product/mutations.pyindex 8fa297a6c9..71b39f1f8c 100644--- a/saleor/graphql/product/mutations.py+++ b/saleor/graphql/product/mutations.py@@ -1,4 +1,5 @@import graphene+from django.template.defaultfilters import slugifyfrom graphene.types import InputObjectTypefrom graphene_file_upload import Uploadfrom graphql_jwt.decorators import permission_required@@ -29,6 +30,13 @@ class CategoryCreateMutation(ModelMutation):description = 'Creates a new category.'model = models.Category+ @classmethod+ def clean_input(cls, info, instance, input, errors):+ cleaned_input = super().clean_input(info, instance, input, errors)+ if 'slug' not in cleaned_input:+ cleaned_input['slug'] = slugify(cleaned_input['name'])+ return cleaned_input+@classmethoddef user_is_allowed(cls, user, input):return user.has_perm('category.edit_category')@@ -173,6 +181,7 @@ class AttributeValueInput(InputObjectType):value = graphene.String(required=True, description='Value of an attribute.')+class ProductInput(graphene.InputObjectType):attributes = graphene.List(AttributeValueInput)available_on = graphene.String()