Skip to content

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

Changes after code review

Damian Wd314f170214f
diff --git a/.isort.cfg b/.isort.cfg
index 332869e190..2fc6b32761 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -1,2 +1,2 @@
[settings]
-known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
+known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,tqdm,versatileimagefield
diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.py
index 1368146825..cbb186cdda 100644
--- a/saleor/graphql/product/tests/test_product.py
+++ b/saleor/graphql/product/tests/test_product.py
@@ -456,10 +456,10 @@ def test_products_query_with_filter_collection(
@pytest.mark.parametrize(
"products_filter",
[
+ {"price": {"gte": 1.0, "lte": 2.0}},
{"minimalPrice": {"gte": 1.0, "lte": 2.0}},
{"isPublished": False},
{"search": "Juice1"},
- {"price": {"gte": 1.0, "lte": 2.0}},
],
)
def test_products_query_with_filter(
@@ -1500,8 +1500,8 @@ def test_update_product(
$descriptionJson: JSONString!,
$isPublished: Boolean!,
$chargeTaxes: Boolean!,
- $basePrice: Decimal!,
$taxCode: String!,
+ $basePrice: Decimal!,
$attributes: [AttributeValueInput!]) {
productUpdate(
id: $productId,
@@ -1509,11 +1509,11 @@ def test_update_product(
category: $categoryId,
name: $name,
slug: $slug,
- basePrice: $basePrice,
descriptionJson: $descriptionJson,
isPublished: $isPublished,
chargeTaxes: $chargeTaxes,
taxCode: $taxCode,
+ basePrice: $basePrice,
attributes: $attributes
}) {
product {
@@ -1581,11 +1581,11 @@ def test_update_product(
"categoryId": category_id,
"name": product_name,
"slug": product_slug,
- "basePrice": basePrice,
"descriptionJson": other_description_json,
"isPublished": product_is_published,
"chargeTaxes": product_charge_taxes,
"taxCode": product_tax_rate,
+ "basePrice": basePrice,
"attributes": [{"id": attribute_id, "values": ["Rainbow"]}],
}
@@ -4275,8 +4275,8 @@ mutation createProduct(
category: $category,
productType: $productType,
name: $name,
- basePrice: $basePrice,
sku: $sku,
+ basePrice: $basePrice,
weight: $weight
})
{
@@ -4327,8 +4327,8 @@ def test_create_product_with_weight_variable(
"category": category_id,
"productType": product_type_id,
"name": "Test",
- "basePrice": Decimal("19"),
"sku": "23434",
+ "basePrice": Decimal("19"),
"weight": weight,
}
response = staff_api_client.post_graphql(
diff --git a/saleor/graphql/product/tests/test_product_pagination.py b/saleor/graphql/product/tests/test_product_pagination.py
index 874449ab02..cf852ec9aa 100644
--- a/saleor/graphql/product/tests/test_product_pagination.py
+++ b/saleor/graphql/product/tests/test_product_pagination.py
@@ -402,14 +402,14 @@ QUERY_PRODUCTS_PAGINATION = """
{"field": "NAME", "direction": "DESC"},
["ProductProduct2", "ProductProduct1", "Product3"],
),
- (
- {"field": "TYPE", "direction": "ASC"},
- ["Product1", "Product3", "ProductProduct2"],
- ),
(
{"field": "PRICE", "direction": "ASC"},
["Product2", "ProductProduct2", "Product1"],
),
+ (
+ {"field": "TYPE", "direction": "ASC"},
+ ["Product1", "Product3", "ProductProduct2"],
+ ),
(
{"field": "PUBLISHED", "direction": "ASC"},
["Product2", "ProductProduct1", "Product1"],
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 1ad18bd438..23efa9bf2b 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -8,15 +8,12 @@ from django.db import models
from django.db.models import Case, Count, F, FilteredRelation, Q, Value, When
from django.urls import reverse
from django.utils.encoding import smart_text
-from django.utils.text import slugify
from django_measurement.models import MeasurementField
from django_prices.models import MoneyField
from draftjs_sanitizer import clean_draft_js
from measurement.measures import Weight
from mptt.managers import TreeManager
from mptt.models import MPTTModel
-from prices import MoneyRange
-from text_unidecode import unidecode
from versatileimagefield.fields import PPOIField, VersatileImageField
from ..core.db.fields import SanitizedJSONField