Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add ability to create images without images
Adam Bogdał2b5b0b8e0ff4
diff --git a/app.json b/app.jsonindex 31ea29fa34..3045f095c3 100644--- a/app.json+++ b/app.json@@ -38,7 +38,7 @@}},"scripts": {- "postdeploy": "python manage.py migrate && python manage.py populatedb --createsuperuser"+ "postdeploy": "python manage.py migrate && python manage.py populatedb --createsuperuser --withoutimages"},"addons": ["heroku-postgresql:hobby-dev",diff --git a/saleor/product/management/commands/populatedb.py b/saleor/product/management/commands/populatedb.pyindex 168c10dd35..ca006811b2 100644--- a/saleor/product/management/commands/populatedb.py+++ b/saleor/product/management/commands/populatedb.py@@ -16,6 +16,12 @@ class Command(BaseCommand):dest='createsuperuser',default=False,help='Create admin account')+ parser.add_argument(+ '--withoutimages',+ action='store_true',+ dest='withoutimages',+ default=False,+ help='Don\'t create product images')def make_database_faster(self):'''Sacrifices some of the safeguards of sqlite3 for speed@@ -30,7 +36,8 @@ class Command(BaseCommand):def handle(self, *args, **options):self.make_database_faster()- for msg in create_items(self.placeholders_dir, 40):+ create_images = not options['withoutimages']+ for msg in create_items(self.placeholders_dir, 40, create_images):self.stdout.write(msg)for msg in create_users(20):self.stdout.write(msg)diff --git a/utils/create_random_data.py b/utils/create_random_data.pyindex 9453173dc1..b9d716b9e6 100644--- a/utils/create_random_data.py+++ b/utils/create_random_data.py@@ -85,15 +85,15 @@ def create_product_images(product, how_many, placeholder_dir):create_product_image(product, placeholder_dir)-def create_items(placeholder_dir, how_many=10):+def create_items(placeholder_dir, how_many=10, create_images=True):default_category = get_or_create_category('Default')- create_images = os.path.exists(placeholder_dir)+ placeholder_images = os.path.exists(placeholder_dir)for i in range(how_many):product = create_product()product.categories.add(default_category)- if create_images:+ if placeholder_images and create_images:create_product_images(product, random.randrange(1, 5), placeholder_dir)num_variants = random.randrange(1, 5)