Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Code review changes
Adam Janike17625d6b9ad
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 5d8b368323..dceb4a5b68 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -7,8 +7,8 @@ from django.db import transactionfrom ...checkout import modelsfrom ...checkout.utils import (add_variant_to_cart, add_voucher_to_cart, change_billing_address_in_cart,- change_shipping_address_in_cart, create_order, get_or_create_user_cart,- get_taxes_for_cart, get_voucher_for_cart, clean_checkout,+ change_shipping_address_in_cart, clean_checkout, create_order,+ get_or_create_user_cart, get_taxes_for_cart, get_voucher_for_cart,recalculate_cart_discount, remove_voucher_from_cart)from ...core import analyticsfrom ...core.exceptions import InsufficientStock@@ -32,7 +32,7 @@ def clean_shipping_method(checkout, method, discounts, taxes, country_code=None, remove=True):# FIXME Add tests for this functionif not method:- return+ return Noneif not checkout.is_shipping_required():raise ValidationError('This checkout does not requires shipping.')@@ -209,8 +209,6 @@ class CheckoutLinesAdd(BaseMutation):checkout = cls.get_node_or_error(info, checkout_id, only_type=Checkout, field='checkout_id')- variants, quantities = None, None-variant_ids = [line.get('variant_id') for line in lines]variants = cls.get_nodes_or_error(variant_ids, 'variant_id', ProductVariant)diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.pyindex b4c163977f..ace5733f68 100644--- a/saleor/graphql/core/mutations.py+++ b/saleor/graphql/core/mutations.py@@ -4,7 +4,7 @@ from textwrap import dedentimport graphenefrom django.contrib.auth import get_user_modelfrom django.core.exceptions import (- ImproperlyConfigured, NON_FIELD_ERRORS, ValidationError)+ NON_FIELD_ERRORS, ImproperlyConfigured, ValidationError)from django.db.models.fields.files import FileFieldfrom graphene.types.mutation import MutationOptionsfrom graphene_django.registry import get_global_registry@@ -85,7 +85,6 @@ class BaseMutation(graphene.Mutation):if not node_id:return None- node = Nonetry:node = graphene.Node.get_node_from_global_id(info, node_id, only_type)@@ -99,7 +98,6 @@ class BaseMutation(graphene.Mutation):@classmethoddef get_nodes_or_error(cls, ids, field, only_type=None):- instances = Nonetry:instances = get_nodes(ids, only_type)except GraphQLError as e:@@ -432,8 +430,7 @@ class BaseBulkMutation(BaseMutation):if errors:errors = validation_error_to_error_type(errors)return cls(errors=errors, count=count)- else:- return cls(count=count)+ return cls(count=count)class ModelBulkDeleteMutation(BaseBulkMutation):diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.pyindex f092420cef..7638275c1a 100644--- a/saleor/graphql/menu/mutations.py+++ b/saleor/graphql/menu/mutations.py@@ -67,22 +67,22 @@ class MenuCreate(ModelMutation):url = item.get('url')if len([i for i in [category, collection, page, url] if i]) > 1:raise ValidationError({'items': 'More than one item provided.'})- else:- if category:- category = cls.get_node_or_error(- info, category, field='items', only_type=Category)- item['category'] = category- elif collection:- collection = cls.get_node_or_error(- info, collection, field='items', only_type=Collection)- item['collection'] = collection- elif page:- page = cls.get_node_or_error(- info, page, field='items', only_type=Page)- item['page'] = page- elif not url:- raise ValidationError({'items': 'No menu item provided.'})- items.append(item)++ if category:+ category = cls.get_node_or_error(+ info, category, field='items', only_type=Category)+ item['category'] = category+ elif collection:+ collection = cls.get_node_or_error(+ info, collection, field='items', only_type=Collection)+ item['collection'] = collection+ elif page:+ page = cls.get_node_or_error(+ info, page, field='items', only_type=Page)+ item['page'] = page+ elif not url:+ raise ValidationError({'items': 'No menu item provided.'})+ items.append(item)cleaned_input['items'] = itemsreturn cleaned_input@@ -225,8 +225,5 @@ class AssignNavigation(BaseMutation):elif navigation_type == NavigationType.SECONDARY:site_settings.bottom_menu = menusite_settings.save(update_fields=['bottom_menu'])- else:- raise AssertionError(- 'Unknown navigation type: %s' % navigation_type)return AssignNavigation(menu=menu)diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.pyindex 76587b3ecc..3948181d51 100644--- a/saleor/graphql/shop/mutations.py+++ b/saleor/graphql/shop/mutations.py@@ -102,12 +102,11 @@ class ShopFetchTaxRates(BaseMutation):@classmethoddef perform_mutation(cls, root, info):- if settings.VATLAYER_ACCESS_KEY:- call_command('get_vat_rates')- else:+ if not settings.VATLAYER_ACCESS_KEY:raise ValidationError('Could not fetch tax rates. Make sure you have supplied a ''valid API Access Key.')+ call_command('get_vat_rates')return ShopFetchTaxRates(shop=Shop())