Fix sample data generator

This commit is contained in:
warlordjones
2019-10-01 19:22:15 +01:00
parent 36ac122f7a
commit d89d449ab1
2 changed files with 0 additions and 29 deletions

View File

@@ -1,27 +0,0 @@
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
from django.conf import settings
class Command(BaseCommand):
help = 'Creates a super user'
def handle(self, *args, **options):
if not (settings.DEBUG or settings.STAGING):
raise CommandError('You cannot run this command in production')
self.create_user_object('super', True, True)
self.create_user_object('staff', True)
self.create_user_object('basic')
@staticmethod
def create_user_object(name, staff=False, superuser=False):
user, created = User.objects.get_or_create(
username=name, defaults={'email': '{}@{}.com'.format(name, name),
'first_name': name.title(), 'last_name': 'User', 'is_superuser': superuser,
'is_staff': staff})
if created:
user.set_password(name)
user.save()

View File

@@ -17,8 +17,6 @@ class Command(BaseCommand):
random.seed('Some object to see the random number generator')
call_command('createBaseUsers')
self.create_categories()
self.create_statuses()
self.create_suppliers()