Skip to content

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

Add slug field to ProductType and Warehouse, update in Collection and Category

IKarbowiakfe136b7989d7
diff --git a/saleor/product/migrations/0112_auto_20200127_0523.py b/saleor/product/migrations/0112_auto_20200127_0523.py
new file mode 100644
index 0000000000..62940bfb47
--- /dev/null
+++ b/saleor/product/migrations/0112_auto_20200127_0523.py
@@ -0,0 +1,29 @@
+# Generated by Django 2.2.9 on 2020-01-27 11:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("product", "0111_auto_20191209_0437"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="producttype",
+ name="slug",
+ field=models.SlugField(default="", unique=True),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name="category",
+ name="slug",
+ field=models.SlugField(max_length=128, unique=True),
+ ),
+ migrations.AlterField(
+ model_name="collection",
+ name="slug",
+ field=models.SlugField(max_length=128, unique=True),
+ ),
+ ]
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 4ac3f92396..190b0e1c8e 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -47,7 +47,7 @@ if TYPE_CHECKING:
class Category(MPTTModel, ModelWithMetadata, SeoModel):
name = models.CharField(max_length=128)
- slug = models.SlugField(max_length=128)
+ slug = models.SlugField(max_length=128, unique=True)
description = models.TextField(blank=True)
description_json = JSONField(blank=True, default=dict)
parent = models.ForeignKey(
@@ -98,6 +98,7 @@ class CategoryTranslation(SeoModelTranslation):
class ProductType(ModelWithMetadata):
name = models.CharField(max_length=128)
+ slug = models.SlugField(max_length=50, unique=True)
has_variants = models.BooleanField(default=True)
is_shipping_required = models.BooleanField(default=True)
is_digital = models.BooleanField(default=False)
@@ -882,7 +883,7 @@ class CollectionProduct(SortableModel):
class Collection(SeoModel, ModelWithMetadata, PublishableModel):
name = models.CharField(max_length=128, unique=True)
- slug = models.SlugField(max_length=128)
+ slug = models.SlugField(max_length=128, unique=True)
products = models.ManyToManyField(
Product,
blank=True,
diff --git a/saleor/warehouse/migrations/0003_warehouse_slug.py b/saleor/warehouse/migrations/0003_warehouse_slug.py
new file mode 100644
index 0000000000..ef93b3e3b0
--- /dev/null
+++ b/saleor/warehouse/migrations/0003_warehouse_slug.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.2.9 on 2020-01-27 11:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("warehouse", "0002_auto_20200123_0036"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="warehouse",
+ name="slug",
+ field=models.SlugField(default="", unique=True),
+ preserve_default=False,
+ ),
+ ]
diff --git a/saleor/warehouse/models.py b/saleor/warehouse/models.py
index 0b8ce8a8b7..b5b49c0781 100644
--- a/saleor/warehouse/models.py
+++ b/saleor/warehouse/models.py
@@ -22,6 +22,7 @@ class WarehouseQueryset(models.QuerySet):
class Warehouse(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=255)
+ slug = models.SlugField(max_length=50, unique=True)
company_name = models.CharField(blank=True, max_length=255)
shipping_zones = models.ManyToManyField(ShippingZone, blank=True)