Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix review remarks

fowczarekd63b70f2376e
diff --git a/saleor/graphql/core/types/money.py b/saleor/graphql/core/types/money.py
index 0e6fafcf9a..12b3741277 100644
--- a/saleor/graphql/core/types/money.py
+++ b/saleor/graphql/core/types/money.py
@@ -61,7 +61,8 @@ class VAT(graphene.ObjectType):
reduced_rates = graphene.List(
lambda: ReducedRate,
description=dedent('''
- Country\'s VAT rate exceptions for specific types of goods.'''))
+ Country\'s VAT rate exceptions for specific types of goods.'''),
+ required=True)
class Meta:
description = 'Represents a VAT rate for a country.'
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 11c0a7868b..11ce43d340 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1813,9 +1813,9 @@ type Shop {
permissions: [PermissionDisplay]!
phonePrefixes: [String]!
headerText: String
- includeTaxesInPrices: Boolean
- displayGrossPrices: Boolean
- chargeTaxesOnShipping: Boolean
+ includeTaxesInPrices: Boolean!
+ displayGrossPrices: Boolean!
+ chargeTaxesOnShipping: Boolean!
trackInventoryByDefault: Boolean
defaultWeightUnit: WeightUnitsEnum
}
@@ -2015,7 +2015,7 @@ input UserCreateInput {
type VAT {
countryCode: String!
standardRate: Float
- reducedRates: [ReducedRate]
+ reducedRates: [ReducedRate]!
}
type VariantImageAssign {
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.py
index 5960ae144f..015c6a392e 100644
--- a/saleor/graphql/shop/mutations.py
+++ b/saleor/graphql/shop/mutations.py
@@ -1,7 +1,5 @@
-import logging
-
import graphene
-from django.core.exceptions import ImproperlyConfigured
+from django.conf import settings
from django.core.management import call_command
from graphql_jwt.decorators import permission_required
@@ -11,8 +9,6 @@ from ..core.mutations import BaseMutation
from ..product.types import Collection
from .types import AuthorizationKey, AuthorizationKeyType, Shop
-logger = logging.getLogger(__name__)
-
class ShopSettingsInput(graphene.InputObjectType):
header_text = graphene.String(description='Header text')
@@ -99,14 +95,12 @@ class ShopFetchTaxRates(BaseMutation):
@permission_required('site.manage_settings')
def mutate(cls, root, info):
errors = []
- try:
+ if settings.VATLAYER_ACCESS_KEY:
call_command('get_vat_rates')
- except ImproperlyConfigured as exc:
- logger.exception(exc)
+ else:
cls.add_error(
errors, None, 'Could not fetch tax rates. '
- 'Make sure you have supplied a valid API Access Key. '
- 'Check the server logs for more information about this error.')
+ 'Make sure you have supplied a valid API Access Key.')
return ShopFetchTaxRates(shop=Shop(), errors=errors)
diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.py
index 0bafd1939a..b5abf085a7 100644
--- a/saleor/graphql/shop/types.py
+++ b/saleor/graphql/shop/types.py
@@ -97,11 +97,11 @@ class Shop(graphene.ObjectType):
required=True)
header_text = graphene.String(description='Header text')
include_taxes_in_prices = graphene.Boolean(
- description='Include taxes in prices')
+ description='Include taxes in prices', required=True)
display_gross_prices = graphene.Boolean(
- description='Display prices with tax in store')
+ description='Display prices with tax in store', required=True)
charge_taxes_on_shipping = graphene.Boolean(
- description='Charge taxes on shipping')
+ description='Charge taxes on shipping', required=True)
track_inventory_by_default = graphene.Boolean(
description='Enable inventory tracking')
default_weight_unit = WeightUnitsEnum(description='Default weight unit')
diff --git a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts
index d59dd0c64f..1ee4fab48b 100644
--- a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts
+++ b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts
@@ -24,9 +24,9 @@ export interface ShopInfo_shop {
defaultCountry: ShopInfo_shop_defaultCountry | null;
defaultCurrency: string;
defaultWeightUnit: WeightUnitsEnum | null;
- displayGrossPrices: boolean | null;
+ displayGrossPrices: boolean;
domain: ShopInfo_shop_domain;
- includeTaxesInPrices: boolean | null;
+ includeTaxesInPrices: boolean;
name: string;
trackInventoryByDefault: boolean | null;
}
diff --git a/saleor/static/dashboard-next/taxes/types/CountryFragment.ts b/saleor/static/dashboard-next/taxes/types/CountryFragment.ts
index ca07358a99..78ae7cf8d5 100644
--- a/saleor/static/dashboard-next/taxes/types/CountryFragment.ts
+++ b/saleor/static/dashboard-next/taxes/types/CountryFragment.ts
@@ -16,7 +16,7 @@ export interface CountryFragment_vat_reducedRates {
export interface CountryFragment_vat {
__typename: "VAT";
standardRate: number | null;
- reducedRates: (CountryFragment_vat_reducedRates | null)[] | null;
+ reducedRates: (CountryFragment_vat_reducedRates | null)[];
}
export interface CountryFragment {
diff --git a/saleor/static/dashboard-next/taxes/types/CountryList.ts b/saleor/static/dashboard-next/taxes/types/CountryList.ts
index 3aa9d19c35..90393b767b 100644
--- a/saleor/static/dashboard-next/taxes/types/CountryList.ts
+++ b/saleor/static/dashboard-next/taxes/types/CountryList.ts
@@ -16,7 +16,7 @@ export interface CountryList_shop_countries_vat_reducedRates {
export interface CountryList_shop_countries_vat {
__typename: "VAT";
standardRate: number | null;
- reducedRates: (CountryList_shop_countries_vat_reducedRates | null)[] | null;
+ reducedRates: (CountryList_shop_countries_vat_reducedRates | null)[];
}
export interface CountryList_shop_countries {
@@ -28,9 +28,9 @@ export interface CountryList_shop_countries {
export interface CountryList_shop {
__typename: "Shop";
- chargeTaxesOnShipping: boolean | null;
- includeTaxesInPrices: boolean | null;
- displayGrossPrices: boolean | null;
+ chargeTaxesOnShipping: boolean;
+ includeTaxesInPrices: boolean;
+ displayGrossPrices: boolean;
countries: (CountryList_shop_countries | null)[];
}
diff --git a/saleor/static/dashboard-next/taxes/types/FetchTaxes.ts b/saleor/static/dashboard-next/taxes/types/FetchTaxes.ts
index ebb08433d4..95d1f443e7 100644
--- a/saleor/static/dashboard-next/taxes/types/FetchTaxes.ts
+++ b/saleor/static/dashboard-next/taxes/types/FetchTaxes.ts
@@ -22,7 +22,7 @@ export interface FetchTaxes_shopFetchTaxRates_shop_countries_vat_reducedRates {
export interface FetchTaxes_shopFetchTaxRates_shop_countries_vat {
__typename: "VAT";
standardRate: number | null;
- reducedRates: (FetchTaxes_shopFetchTaxRates_shop_countries_vat_reducedRates | null)[] | null;
+ reducedRates: (FetchTaxes_shopFetchTaxRates_shop_countries_vat_reducedRates | null)[];
}
export interface FetchTaxes_shopFetchTaxRates_shop_countries {
diff --git a/saleor/static/dashboard-next/taxes/types/ShopTaxesFragment.ts b/saleor/static/dashboard-next/taxes/types/ShopTaxesFragment.ts
index 5864d1b34b..066a655186 100644
--- a/saleor/static/dashboard-next/taxes/types/ShopTaxesFragment.ts
+++ b/saleor/static/dashboard-next/taxes/types/ShopTaxesFragment.ts
@@ -7,7 +7,7 @@
export interface ShopTaxesFragment {
__typename: "Shop";
- chargeTaxesOnShipping: boolean | null;
- includeTaxesInPrices: boolean | null;
- displayGrossPrices: boolean | null;
+ chargeTaxesOnShipping: boolean;
+ includeTaxesInPrices: boolean;
+ displayGrossPrices: boolean;
}
diff --git a/saleor/static/dashboard-next/taxes/types/UpdateTaxSettings.ts b/saleor/static/dashboard-next/taxes/types/UpdateTaxSettings.ts
index e6f1ad8ff4..6e3363fd56 100644
--- a/saleor/static/dashboard-next/taxes/types/UpdateTaxSettings.ts
+++ b/saleor/static/dashboard-next/taxes/types/UpdateTaxSettings.ts
@@ -15,9 +15,9 @@ export interface UpdateTaxSettings_shopSettingsUpdate_errors {
export interface UpdateTaxSettings_shopSettingsUpdate_shop {
__typename: "Shop";
- chargeTaxesOnShipping: boolean | null;
- includeTaxesInPrices: boolean | null;
- displayGrossPrices: boolean | null;
+ chargeTaxesOnShipping: boolean;
+ includeTaxesInPrices: boolean;
+ displayGrossPrices: boolean;
}
export interface UpdateTaxSettings_shopSettingsUpdate {
diff --git a/tests/api/test_shop.py b/tests/api/test_shop.py
index 4d9fe78c3f..c02ae0466c 100644
--- a/tests/api/test_shop.py
+++ b/tests/api/test_shop.py
@@ -486,7 +486,8 @@ MUTATION_SHOP_FETCH_TAX_RATES = """
message
}
}
- }"""
+ }
+ """
def test_shop_fetch_tax_rates_no_api_access_key(
@@ -497,14 +498,15 @@ def test_shop_fetch_tax_rates_no_api_access_key(
content = get_graphql_content(response)
data = content['data']['shopFetchTaxRates']
error_message =('Could not fetch tax rates. '
- 'Make sure you have supplied a valid API Access Key. '
- 'Check the server logs for more information about this error.')
+ 'Make sure you have supplied a valid API Access Key.')
assert data['errors'][0]['message'] == error_message
@patch('saleor.graphql.shop.mutations.call_command')
def test_shop_fetch_tax_rates(
- mock_call_command, staff_api_client, permission_manage_settings):
+ mock_call_command, staff_api_client, permission_manage_settings,
+ settings):
+ settings.VATLAYER_ACCESS_KEY = 'KEY'
staff_api_client.user.user_permissions.add(permission_manage_settings)
response = staff_api_client.post_graphql(
MUTATION_SHOP_FETCH_TAX_RATES)