🤡(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:
5
src/backend/demo/defaults.py
Normal file
5
src/backend/demo/defaults.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
"""Parameters that define how the demo site will be built."""
|
||||||
|
|
||||||
|
NB_OBJECTS = {
|
||||||
|
"users": 100,
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ from faker import Faker
|
|||||||
|
|
||||||
from core import models
|
from core import models
|
||||||
|
|
||||||
|
from demo import defaults
|
||||||
|
|
||||||
fake = Faker()
|
fake = Faker()
|
||||||
|
|
||||||
logger = logging.getLogger("impress.commands.demo.create_demo")
|
logger = logging.getLogger("impress.commands.demo.create_demo")
|
||||||
@@ -108,6 +110,21 @@ def create_demo(stdout):
|
|||||||
|
|
||||||
queue = BulkQueue(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 Timeit(stdout, "Creating Template"):
|
||||||
with open(
|
with open(
|
||||||
file="demo/data/template/code.txt", mode="r", encoding="utf-8"
|
file="demo/data/template/code.txt", mode="r", encoding="utf-8"
|
||||||
@@ -121,6 +138,7 @@ def create_demo(stdout):
|
|||||||
|
|
||||||
queue.push(
|
queue.push(
|
||||||
models.Template(
|
models.Template(
|
||||||
|
id="baca9e2a-59fb-42ef-b5c6-6f6b05637111",
|
||||||
title="Demo Template",
|
title="Demo Template",
|
||||||
description="This is the demo template",
|
description="This is the demo template",
|
||||||
code=code_data,
|
code=code_data,
|
||||||
|
|||||||
Reference in New Issue
Block a user