Skip to content

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

Assign random addres to demo admin

Krzysztof Wolski0912a3a641ce
diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.py
index 3db8748a92..37951bfd5c 100644
--- a/saleor/core/management/commands/populatedb.py
+++ b/saleor/core/management/commands/populatedb.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.db import connection
@@ -5,7 +7,7 @@ from django.db import connection
from ...utils.random_data import (
create_orders, create_users, create_shipping_methods,
create_products_by_schema, create_product_sales, create_vouchers,
- set_featured_products)
+ set_featured_products, add_address_to_admin)
from ...utils import create_superuser
@@ -69,5 +71,6 @@ class Command(BaseCommand):
credentials = {'email': '[email protected]', 'password': 'admin'}
msg = create_superuser(credentials)
self.stdout.write(msg)
+ add_address_to_admin(credentials['email'])
if not options['withoutsearch']:
self.populate_search_index()
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 994897b8c3..838e60760c 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -20,6 +20,8 @@ from ...product.models import (AttributeChoiceValue, Category, Product,
ProductVariant, Stock, StockLocation)
from ...shipping.models import ANY_COUNTRY, ShippingMethod
from ...userprofile.models import Address, User
+from ...userprofile.utils import store_user_address
+
fake = Factory.create()
STOCK_LOCATION = 'default'
@@ -509,3 +511,9 @@ def set_featured_products(how_many=8):
pks = Product.objects.order_by('?')[:how_many].values_list('pk', flat=True)
Product.objects.filter(pk__in=pks).update(is_featured=True)
yield 'Featured products created'
+
+
+def add_address_to_admin(email):
+ address = create_address()
+ user = User.objects.get(email=email)
+ store_user_address(user, address, True, True)