🤡(demo) generate dummy user

To search users we need to have some dummy data users.
We add some dummy users when we run the `make demo`
command.
This commit is contained in:
Anthony LC
2024-05-30 15:57:11 +02:00
committed by Anthony LC
parent 1e62320803
commit 327a5f2ed4
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
"""Parameters that define how the demo site will be built."""
NB_OBJECTS = {
"users": 100,
}

View File

@@ -14,6 +14,8 @@ from faker import Faker
from core import models
from demo import defaults
fake = Faker()
logger = logging.getLogger("impress.commands.demo.create_demo")
@@ -108,6 +110,21 @@ def create_demo(stdout):
queue = BulkQueue(stdout)
with Timeit(stdout, "Creating users"):
for i in range(defaults.NB_OBJECTS["users"]):
queue.push(
models.User(
admin_email=f"user{i:d}@example.com",
email=f"user{i:d}@example.com",
password="!",
is_superuser=False,
is_active=True,
is_staff=False,
language=random.choice(settings.LANGUAGES)[0],
)
)
queue.flush()
with Timeit(stdout, "Creating Template"):
with open(
file="demo/data/template/code.txt", mode="r", encoding="utf-8"
@@ -121,6 +138,7 @@ def create_demo(stdout):
queue.push(
models.Template(
id="baca9e2a-59fb-42ef-b5c6-6f6b05637111",
title="Demo Template",
description="This is the demo template",
code=code_data,