Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Make collection name non-unique (#8986)
Rafał Pitońb497f8d82426
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 87b4d0051f..e23d71a046 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -30,6 +30,7 @@ All notable, unreleased changes to this project will be documented in this file.- Fix crash when querying external shipping method's `translation` field - #8971 by @rafalp- Add `COLLECTION_CREATED`, `COLLECTION_UPDATED`, `COLLECTION_DELETED` events and webhooks - #8974 by @rafalp- Fix crash when too long translation strings were passed to `translate` mutations - #8942 by rafalp+- Make collections names non-unique - #8986 by @rafalp# 3.0.0 [Unreleased]diff --git a/saleor/graphql/product/sorters.py b/saleor/graphql/product/sorters.pyindex 05e6361d27..e329e11056 100644--- a/saleor/graphql/product/sorters.py+++ b/saleor/graphql/product/sorters.py@@ -70,10 +70,10 @@ class CategorySortingInput(ChannelSortInputObjectType):class CollectionSortField(graphene.Enum):- NAME = ["name"]- AVAILABILITY = ["is_published", "name"]- PRODUCT_COUNT = ["product_count", "name"]- PUBLICATION_DATE = ["publication_date", "name"]+ NAME = ["name", "slug"]+ AVAILABILITY = ["is_published", "slug"]+ PRODUCT_COUNT = ["product_count", "slug"]+ PUBLICATION_DATE = ["publication_date", "slug"]@propertydef description(self):diff --git a/saleor/graphql/product/tests/deprecated/test_product.py b/saleor/graphql/product/tests/deprecated/test_product.pyindex d389bbe712..8223a09469 100644--- a/saleor/graphql/product/tests/deprecated/test_product.py+++ b/saleor/graphql/product/tests/deprecated/test_product.py@@ -358,7 +358,7 @@ def test_collections_query_with_sort(content = get_graphql_content(response)collections = content["data"]["collections"]["edges"]- for order, collection_name in enumerate(["Coll2", "Coll1", "Coll3"]):+ for order, collection_name in enumerate(["Coll2", "Coll3", "Coll1"]):assert collections[order]["node"]["name"] == collection_nameassert any([str(warning.message) == DEPRECATION_WARNING_MESSAGE for warning in warns]diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.pyindex b319d9c8ad..a3ac769666 100644--- a/saleor/graphql/product/tests/test_product.py+++ b/saleor/graphql/product/tests/test_product.py@@ -10642,9 +10642,9 @@ def test_collections_query_with_sort():collections = Collection.objects.bulk_create([- Collection(name="Coll1", slug="collection-published1"),- Collection(name="Coll2", slug="collection-unpublished2"),- Collection(name="Coll3", slug="collection-published"),+ Collection(name="Coll1", slug="collection-1"),+ Collection(name="Coll2", slug="collection-2"),+ Collection(name="Coll3", slug="collection-3"),])published = (True, False, True)diff --git a/saleor/product/migrations/0158_auto_20220120_1633.py b/saleor/product/migrations/0158_auto_20220120_1633.pynew file mode 100644index 0000000000..9fddd0c8b9--- /dev/null+++ b/saleor/product/migrations/0158_auto_20220120_1633.py@@ -0,0 +1,18 @@+# Generated by Django 3.2.11 on 2022-01-20 16:33++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("product", "0157_update_product_search_document"),+ ]++ operations = [+ migrations.AlterField(+ model_name="collection",+ name="name",+ field=models.CharField(max_length=250),+ ),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex a9547b57b8..7b51d728a8 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -846,7 +846,7 @@ class CollectionsQueryset(models.QuerySet):class Collection(SeoModel, ModelWithMetadata):- name = models.CharField(max_length=250, unique=True)+ name = models.CharField(max_length=250)slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)products = models.ManyToManyField(Product,