Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve naming
Adam Janika2cb6e56a68a
diff --git a/saleor/graphql/core/types.py b/saleor/graphql/core/types.pyindex bd5867604f..2b48871d50 100644--- a/saleor/graphql/core/types.py+++ b/saleor/graphql/core/types.py@@ -100,8 +100,8 @@ class PermissionDisplay(graphene.ObjectType):class SeoInput(graphene.InputObjectType):- seo_title = graphene.String(description='SEO title.')- seo_description = graphene.String(description='SEO description.')+ title = graphene.String(description='SEO title.')+ description = graphene.String(description='SEO description.')class TaxedMoney(graphene.ObjectType):diff --git a/saleor/graphql/core/utils.py b/saleor/graphql/core/utils.pyindex 2b8cfa6978..5a1702ab5b 100644--- a/saleor/graphql/core/utils.py+++ b/saleor/graphql/core/utils.py@@ -1,6 +1,6 @@-def handle_seo_fields(data):+def clean_seo_fields(data):"""Extract and assign seo fields to given dictionary."""- seo_fields = data.pop('seo_fields', None)+ seo_fields = data.pop('seo', None)if seo_fields:- data['seo_title'] = seo_fields.get('seo_title')- data['seo_description'] = seo_fields.get('seo_description')+ data['seo_title'] = seo_fields.get('title')+ data['seo_description'] = seo_fields.get('description')diff --git a/saleor/graphql/page/mutations.py b/saleor/graphql/page/mutations.pyindex c1b3ccca49..83ba2b5b54 100644--- a/saleor/graphql/page/mutations.py+++ b/saleor/graphql/page/mutations.py@@ -3,7 +3,7 @@ import graphenefrom ...page import modelsfrom ..core.mutations import ModelDeleteMutation, ModelMutationfrom ..core.types import SeoInput-from ..core.utils import handle_seo_fields+from ..core.utils import clean_seo_fieldsclass PageInput(graphene.InputObjectType):@@ -12,7 +12,7 @@ class PageInput(graphene.InputObjectType):content = graphene.String()is_visible = graphene.Boolean(required=True)available_on = graphene.String()- seo_fields = SeoInput(description='Search engine optimization fields.')+ seo = SeoInput(description='Search engine optimization fields.')class PageCreate(ModelMutation):@@ -31,7 +31,7 @@ class PageCreate(ModelMutation):@classmethoddef clean_input(cls, info, instance, input, errors):cleaned_input = super().clean_input(info, instance, input, errors)- handle_seo_fields(cleaned_input)+ clean_seo_fields(cleaned_input)return cleaned_inputdiff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 8ac94908f0..b75057f33e 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -7,7 +7,7 @@ from graphql_jwt.decorators import permission_requiredfrom ....product import modelsfrom ...core.mutations import BaseMutation, ModelDeleteMutation, ModelMutationfrom ...core.types import Decimal, Error, SeoInput-from ...core.utils import handle_seo_fields+from ...core.utils import clean_seo_fieldsfrom ...utils import get_attributes_dict_from_list, get_node, get_nodesfrom ..types import Collection, Product, ProductImage@@ -20,7 +20,7 @@ class CategoryInput(graphene.InputObjectType):ID of the parent category. If empty, category will be top levelcategory.''')slug = graphene.String(description='Category slug')- seo_fields = SeoInput(description='Search engine optimization fields.')+ seo = SeoInput(description='Search engine optimization fields.')class CategoryCreate(ModelMutation):@@ -37,7 +37,7 @@ class CategoryCreate(ModelMutation):cleaned_input = super().clean_input(info, instance, input, errors)if 'slug' not in cleaned_input:cleaned_input['slug'] = slugify(cleaned_input['name'])- handle_seo_fields(cleaned_input)+ clean_seo_fields(cleaned_input)return cleaned_input@classmethod@@ -81,7 +81,7 @@ class CollectionInput(graphene.InputObjectType):graphene.ID,description='List of products to be added to the collection.')background_image = Upload(description='Background image file.')- seo_fields = SeoInput(description='Search engine optimization fields.')+ seo = SeoInput(description='Search engine optimization fields.')class CollectionCreate(ModelMutation):@@ -101,7 +101,7 @@ class CollectionCreate(ModelMutation):@classmethoddef clean_input(cls, info, instance, input, errors):cleaned_input = super().clean_input(info, instance, input, errors)- handle_seo_fields(cleaned_input)+ clean_seo_fields(cleaned_input)return cleaned_input@@ -201,7 +201,7 @@ class ProductInput(graphene.InputObjectType):product_type = graphene.ID()price = Decimal()tax_rate = graphene.String()- seo_fields = SeoInput(description='Search engine optimization fields.')+ seo = SeoInput(description='Search engine optimization fields.')class ProductCreate(ModelMutation):@@ -232,7 +232,7 @@ class ProductCreate(ModelMutation):attributes = get_attributes_dict_from_list(attributes, slug_to_id_map)cleaned_input['attributes'] = attributes- handle_seo_fields(cleaned_input)+ clean_seo_fields(cleaned_input)return cleaned_input@classmethoddiff --git a/tests/api/test_core.py b/tests/api/test_core.pyindex 75b7141ad2..91a89052a4 100644--- a/tests/api/test_core.py+++ b/tests/api/test_core.py@@ -3,7 +3,7 @@ from phonenumbers import COUNTRY_CODE_TO_REGION_CODEfrom tests.utils import get_graphql_contentfrom saleor.core.permissions import MODELS_PERMISSIONS-from saleor.graphql.core.utils import handle_seo_fields+from saleor.graphql.core.utils import clean_seo_fieldsdef test_shop_endpoint(settings, admin_api_client):@@ -37,12 +37,12 @@ def test_shop_endpoint(settings, admin_api_client):assert len(data['phonePrefixes']) == len(COUNTRY_CODE_TO_REGION_CODE)-def test_handle_seo_fields():- title = 'camel title'+def test_clean_seo_fields():+ title = 'lady title'description = 'fantasy description'- data = {'seo_fields':- {'seo_title': title,- 'seo_description': description}}- handle_seo_fields(data)+ data = {'seo':+ {'title': title,+ 'description': description}}+ clean_seo_fields(data)assert data['seo_title'] == titleassert data['seo_description'] == description