Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
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.pydeleted file mode 100644index 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.pynew file mode 100644index 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.pyindex 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.pyindex 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):- # DEPRECATEDquantity = 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")- # DEPRECATEDstock_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."),)- # DEPRECATEDis_available = graphene.Boolean(description="DEPRECATED: Will be removed in favour of stock. ""Whether the variant is in stock and visible or not."