staging_setup.py 873 B

1234567891011121314151617181920212223242526272829
  1. import os
  2. from stor import create_app, db, cli
  3. from stor.auth.models import Group, User
  4. app = create_app()
  5. cli.register(app)
  6. with app.app_context():
  7. db.create_all()
  8. admin_group = Group(name="admin")
  9. reviewer_group = Group(name="reviewer")
  10. staff_group = Group(name="staff")
  11. standard_group = Group(name="standard")
  12. db.session.add_all([admin_group, reviewer_group, staff_group, standard_group])
  13. db.session.add(User(
  14. id=1,
  15. username="super",
  16. email=os.environ["STAGING_SUPERUSER_EMAIL"],
  17. email_verified=True,
  18. activated=True,
  19. password_rotated=True,
  20. first_name="Super",
  21. last_name="User",
  22. organization_name="DCU",
  23. password=os.environ["STAGING_SUPERUSER_PASSWORD"],
  24. groups=[standard_group, staff_group, reviewer_group, admin_group],
  25. ))
  26. db.session.commit()