Ejemplo n.º 1
0
    def handle(self, *args, **options):
        fake = Factory.create()
        fakeen = Factory.create('en_US')

        number = int(options['number'])
        imgs = os.listdir(
            '/home/hase/technopark/web/AskZaytsev/scripts/test_img')
        #imgsc = len(imgs)
        for i in range(0, number):
            profile = fake.simple_profile()

            u = User.objects.create_user(profile['username'] + str(i + 5000),
                                         profile['mail'],
                                         make_password('qwerty'))
            u.first_name = fakeen.first_name()
            u.last_name = fakeen.last_name()
            u.is_active = True
            u.is_superuser = False
            u.save()

            up = Profile()
            up.user = u
            up.avatar = choice(imgs)
            #up.info = '%s [%s]' % (fakeen.company(), fakeen.catch_phrase())
            up.save()

            self.stdout.write('[%d] added user %s' % (u.id, u.username))
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        fake = Factory.create()
        fakeen = Factory.create('en_US')

        number = int(options['number'])

        for i in range(0, number):
            profile = fake.simple_profile()

            u = User.objects.create_user(profile['username'], profile['mail'],
                                         make_password('qwerty'))
            u.first_name = fakeen.first_name()
            u.last_name = fakeen.last_name()
            u.is_active = True
            u.is_superuser = False
            u.save()

            up = Profile()
            up.user = u
            up.save()
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        fake = Faker('en_US')
        count = int(options['number'])
        added = 0

        for i in range(count):
            profile = fake.simple_profile()
            user = User.objects.create_user(profile['username'], profile['mail'], make_password('test'))
            user.first_name = fake.first_name()
            user.last_name = fake.last_name()
            user.is_active = True
            user.is_superuser = False
            user.save()

            user_profile = Profile()
            user_profile.user = user
            user_profile.save()

            added += 1

        print(added, " Users is added")
Ejemplo n.º 4
0
    def save(self):
        data = self.cleaned_data
        password = data.get('password1')
        u = User()

        u.username = data.get('username')
        u.password = make_password(password)
        u.email = data.get('email')
        u.first_name = data.get('first_name')
        u.last_name = data.get('last_name')
        u.is_active = True
        u.is_superuser = False
        u.save()

        up = Profile()
        up.user = u
        up.info = data.get('info')
        if data.get('avatar') == None:
            up.avatar = "no-avatar.png"
        else:
            up.avatar = data.get('avatar')
        print(up.avatar)
        up.save()
        return authenticate(username=u.username, password=password)