Skip to content

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

Add slug to ProductType and Warehouse in popopulatedb

IKarbowiakf015ebb94089
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index e64679d875..d86b6703f0 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -14,10 +14,13 @@ from django.contrib.sites.models import Site
from django.core.files import File
from django.db.models import Q
from django.utils import timezone
+from django.utils.encoding import smart_text
+from django.utils.text import slugify
from faker import Factory
from faker.providers import BaseProvider
from measurement.measures import Weight
from prices import Money, TaxedMoney
+from text_unidecode import unidecode
from ...account.models import Address, User
from ...account.utils import store_user_address
@@ -937,8 +940,10 @@ def create_shipping_zones():
def create_warehouses():
for shipping_zone in ShippingZone.objects.all():
+ shipping_zone_name = shipping_zone.name
warehouse, _ = Warehouse.objects.update_or_create(
- name=shipping_zone.name,
+ name=shipping_zone_name,
+ slug=slugify(smart_text(unidecode(shipping_zone_name))),
defaults={"company_name": fake.company(), "address": create_address()},
)
warehouse.shipping_zones.add(shipping_zone)
diff --git a/saleor/static/populatedb_data.json b/saleor/static/populatedb_data.json
index f722fd7c12..8bcdd10670 100644
--- a/saleor/static/populatedb_data.json
+++ b/saleor/static/populatedb_data.json
@@ -283,6 +283,7 @@
}
},
"name": "Paint",
+ "slug": "paint",
"has_variants": true,
"is_shipping_required": true,
"is_digital": false,
@@ -303,6 +304,7 @@
}
},
"name": "Music",
+ "slug": "music",
"has_variants": true,
"is_shipping_required": true,
"is_digital": false,
@@ -323,6 +325,7 @@
}
},
"name": "Juice",
+ "slug": "juice",
"has_variants": true,
"is_shipping_required": true,
"is_digital": false,
@@ -343,6 +346,7 @@
}
},
"name": "Wine",
+ "slug": "wine",
"has_variants": false,
"is_shipping_required": true,
"is_digital": false,
@@ -363,6 +367,7 @@
}
},
"name": "Beer",
+ "slug": "beer",
"has_variants": false,
"is_shipping_required": true,
"is_digital": false,
@@ -383,6 +388,7 @@
}
},
"name": "Cushion",
+ "slug": "cushion",
"has_variants": true,
"is_shipping_required": true,
"is_digital": false,
@@ -403,6 +409,7 @@
}
},
"name": "Shoe",
+ "slug": "shoe",
"has_variants": true,
"is_shipping_required": true,
"is_digital": false,
@@ -423,6 +430,7 @@
}
},
"name": "Top (clothing)",
+ "slug": "top-clothing",
"has_variants": true,
"is_shipping_required": true,
"is_digital": false,