Something something like soundcloud but not like soundcloud.
Log in, upload records, done.
Simple, easy, KISS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dbseed.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from models import user_datastore, Config, Role
  2. def make_db_seed(db):
  3. print("== Seeding database")
  4. db.session.begin(subtransactions=True)
  5. try:
  6. seed_config(db)
  7. seed_roles(db)
  8. except: # noqa: E722
  9. db.session.rollback()
  10. raise
  11. def seed_roles(db):
  12. print("++ Seeding roles")
  13. role_usr = Role()
  14. role_usr.name = "user"
  15. role_usr.description = "Simple user"
  16. role_adm = Role()
  17. role_adm.name = "admin"
  18. role_adm.description = "Admin user"
  19. db.session.add(role_usr)
  20. db.session.add(role_adm)
  21. db.session.commit()
  22. def seed_users(db):
  23. print("++ Seeding users")
  24. role_usr = Role()
  25. role_usr.name = "user"
  26. role_usr.description = "Simple user"
  27. role_adm = Role()
  28. role_adm.name = "admin"
  29. role_adm.description = "Admin user"
  30. db.session.add(role_usr)
  31. db.session.add(role_adm)
  32. user_datastore.create_user(
  33. email="dashie@sigpipe.me", password="fluttershy", name="toto", timezone="UTC", roles=[role_adm]
  34. )
  35. db.session.commit()
  36. return
  37. def seed_config(db):
  38. print("++ Seeding config")
  39. a = Config(app_name="My reel2bits instance")
  40. a.app_description = """This is a reel2bits instance"""
  41. db.session.add(a)
  42. db.session.commit()
  43. db.session.commit()
  44. # Bug, two commit necessary