Exemplo n.º 1
0
def load_staff(cli, size, fake, root):
    """
    Load staff
    """
    nb_staffs = size * 3
    cli.stdout.write(u"Nombres de staffs à créer : {}".format(nb_staffs))
    tps1 = time.time()
    cpt = 1
    for i in range(0, nb_staffs):
        while Profile.objects.filter(user__username="******".format(root, cpt)).count() > 0:
            cpt += 1
        profile = StaffProfileFactory(user__username="******".format(root, cpt))
        profile.user.first_name = fake.first_name()
        profile.user.last_name = fake.last_name()
        profile.user.email = fake.free_email()
        profile.user.save()
        profile.site = fake.url()
        profile.biography = fake.paragraph()
        profile.sign = fake.text(max_nb_chars=80)
        profile.last_ip_address = fake.ipv6()
        profile.save()
        cpt += 1
        sys.stdout.write(" Staff {}/{}  \r".format(i + 1, nb_staffs))
        sys.stdout.flush()
    tps2 = time.time()
    cli.stdout.write(u"\nFait en {} sec".format(tps2 - tps1))