def _seed(): db.drop_all() db.create_all() try: count = User.query.count() if count == 0: log.info("Creating initial Admin tenant...") admin_tenant = Organization("Admin") db.session.add(admin_tenant) db.session.commit() log.info("Creating initial admin user...") admin = User("admin", "*****@*****.**") admin.password = generate_password_hash("admin") db.session.add(admin) db.session.commit() log.info(admin.id) admin_tenant.add_user(admin, 100) log.info("Complete, login with admin/admin") return log.info("Seed Complete.") except RuntimeError as ex: log.error("Seed error", exc_info=ex) pass except: pass
def mockup(cls): session = cls.create_session() oscar = User(id='oscar', email='*****@*****.**', password='******') franz = User(id='franz', email='*****@*****.**', password='******') oscar.items.append(Item(list='foo', title='bar')) franz.items.append(Item(list='foo', title='baz')) session.add(oscar) session.add(franz) session.commit()
def mockup(cls): session = cls.create_session() oscar = User(id='oscar', email='*****@*****.**', password='******') session.add(oscar) session.commit()