from django.core.management.base import BaseCommand
from django.db import connection

from ....userprofile.models import User
from ...utils.random_data import (
    create_items, create_orders, create_users, create_shipping_methods)


class Command(BaseCommand):
    help = 'Populate database with test objects'
    placeholders_dir = r'saleor/static/placeholders/'

    def add_arguments(self, parser):
        parser.add_argument(
            '--createsuperuser',
            action='store_true',
            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

        Users are not likely to run this command in a production environment.
        They are even less likely to run it in production while using sqlite3.
        '''
        if 'sqlite3' in connection.settings_dict['ENGINE']:
            cursor = connection.cursor()
            cursor.execute('PRAGMA temp_store = MEMORY;')
            cursor.execute('PRAGMA synchronous = OFF;')

    def handle(self, *args, **options):
        self.make_database_faster()
        create_images = not options['withoutimages']
        for msg in create_shipping_methods():
            self.stdout.write(msg)
        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)
        for msg in create_orders(20):
            self.stdout.write(msg)

        if options['createsuperuser']:
            credentials = {'email': 'admin@example.com', 'password': 'admin'}
            user, created = User.objects.get_or_create(
                email=credentials['email'], defaults={
                    'is_active': True, 'is_staff': True, 'is_superuser': True})
            if created:
                user.set_password(credentials['password'])
                user.save()
                self.stdout.write(
                    'Superuser - %(email)s/%(password)s' % credentials)
            else:
                self.stdout.write(
                    'Superuser already exists - %(email)s' % credentials)

@@ -224,18 +224,57 @@
 _methods
+,%0A    create_items_by_schema, REAL_DATA
 )%0A
-
 %0A%0Aclass 
@@ -837,16 +837,206 @@
 images')
+%0A        parser.add_argument(%0A            '--real-data',%0A            action='store_true',%0A            dest='real_data',%0A            default=False,%0A            help='Create almost real data')
 %0A%0A    de
@@ -1719,32 +1719,171 @@
 dout.write(msg)%0A
+        if options%5B'real_data'%5D:%0A            create_items_by_schema(REAL_DATA, self.placeholders_dir, 40, create_images)%0A        else:%0A    
         for msg 
@@ -1937,24 +1937,28 @@
 te_images):%0A
+    
             

Add a --real-data switch to populatedb command