Skip to content

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

Set default value for country on more dynamic basis

Mira Szewczykd2d543c7ca82
diff --git a/saleor/checkout/migrations/0022_checkout_country.py b/saleor/checkout/migrations/0022_checkout_country.py
deleted file mode 100644
index fc0eed67a5..0000000000
--- a/saleor/checkout/migrations/0022_checkout_country.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated by Django 2.2.7 on 2019-12-19 09:38
-
-import django_countries.fields
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [("checkout", "0022_auto_20191219_1137")]
-
- operations = [
- migrations.AddField(
- model_name="checkout",
- name="country",
- field=django_countries.fields.CountryField(default="US", max_length=2),
- )
- ]
diff --git a/saleor/checkout/migrations/0023_checkout_country.py b/saleor/checkout/migrations/0023_checkout_country.py
new file mode 100644
index 0000000000..493b15a4a8
--- /dev/null
+++ b/saleor/checkout/migrations/0023_checkout_country.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.9 on 2020-01-14 09:30
+
+import django_countries.fields
+from django.db import migrations
+
+import saleor.checkout.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("checkout", "0022_auto_20191219_1137"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="checkout",
+ name="country",
+ field=django_countries.fields.CountryField(
+ default=saleor.checkout.models.get_default_country, max_length=2
+ ),
+ ),
+ ]
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index 1b39c6e9c0..9b74d9a13c 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -45,6 +45,10 @@ class CheckoutQueryset(models.QuerySet):
) # noqa
+def get_default_country():
+ return settings.DEFAULT_COUNTRY
+
+
class Checkout(ModelWithMetadata):
"""A shopping checkout."""
@@ -79,7 +83,7 @@ class Checkout(ModelWithMetadata):
max_length=settings.DEFAULT_CURRENCY_CODE_LENGTH,
default=settings.DEFAULT_CURRENCY,
)
- country = CountryField(default=settings.DEFAULT_COUNTRY)
+ country = CountryField(default=get_default_country)
discount_amount = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 1d39020fb7..51a8ce8313 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -193,7 +193,6 @@ class ProductPricingInfo(BasePricingInfo):
@key(fields="id")
class ProductVariant(CountableDjangoObjectType, MetadataObjectType):
- # DEPRECATED
quantity = graphene.Int(
required=True,
description="DEPRECATED: Will be removed in favour of stock. "
@@ -201,7 +200,6 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):
"including the allocated stock that is waiting for shipment.",
)
quantity_allocated = graphene.Int(required=False, description="DEPRECATED")
- # DEPRECATED
stock_quantity = graphene.Int(
required=True,
description="DEPRECATED: Will be removed in favour to stock. "
@@ -221,7 +219,6 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):
"only meant for displaying."
),
)
- # DEPRECATED
is_available = graphene.Boolean(
description="DEPRECATED: Will be removed in favour of stock. "
"Whether the variant is in stock and visible or not."