Skip to content

Commit

Permalink
fix: demo user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Oct 10, 2024
1 parent 2d6205c commit 709019e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions demo/demoapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def populate(app):
with app.app_context():
app.backend.install(app.config)
with app.backend.session():
if models.User.query():
if app.backend.query(models.User):
return

jane = models.User(
Expand All @@ -38,7 +38,7 @@ def populate(app):
employee_number="1000",
department="east",
)
jane.save()
app.backend.save(jane)

jack = models.User(
formatted_name="Jack Doe",
Expand All @@ -53,7 +53,7 @@ def populate(app):
employee_number="1002",
department="west",
)
jack.save()
app.backend.save(jack)

john = models.User(
formatted_name="John Doe",
Expand All @@ -68,7 +68,7 @@ def populate(app):
employee_number="1001",
department="west",
)
john.save()
app.backend.save(john)

james = models.User(
formatted_name="James Doe",
Expand All @@ -77,28 +77,28 @@ def populate(app):
user_name="james",
emails=["[email protected]"],
)
james.save()
app.backend.save(james)

users = models.Group(
display_name="users",
members=[jane, jack, john, james],
description="The regular users.",
)
users.save()
app.backend.save(users)

users = models.Group(
admins = models.Group(
display_name="admins",
members=[jane],
description="The administrators.",
)
users.save()
app.backend.save(admins)

users = models.Group(
display_name="moderators",
members=[james],
description="People who can manage users.",
)
users.save()
app.backend.save(users)

client1 = models.Client(
client_id_issued_at=datetime.datetime.utcnow(),
Expand All @@ -119,9 +119,9 @@ def populate(app):
response_types=["code", "id_token"],
token_endpoint_auth_method="client_secret_basic",
)
client1.save()
app.backend.save(client1)
client1.audience = [client1]
client1.save()
app.backend.save(client1)

client2 = models.Client(
client_id_issued_at=datetime.datetime.utcnow(),
Expand All @@ -143,9 +143,9 @@ def populate(app):
token_endpoint_auth_method="client_secret_basic",
preconsent=True,
)
client2.save()
app.backend.save(client2)
client2.audience = [client2]
client2.save()
app.backend.save(client2)

fake_users(50)
fake_groups(10, nb_users_max=10)
Expand All @@ -156,6 +156,6 @@ def create_app():
try:
populate(app)
except:
pass
raise

return app

0 comments on commit 709019e

Please sign in to comment.