Ejemplo n.º 1
0
def get_admin_user(_app_settings):
    admin = User.find_by_username("admin")
    if admin is None:
        admin = User("admin")
        admin.password = _app_settings['LIFEMONITOR_ADMIN_PASSWORD']
        admin.id = 1
        lm_db.db.session.add(admin)
        lm_db.db.session.commit()
    return admin
Ejemplo n.º 2
0
def get_admin_user():
    admin = User.find_by_username("admin")
    if admin is None:
        admin = User("admin")
        admin.password = "******"
        admin.id = 1
        lm_db.db.session.add(admin)
        lm_db.db.session.commit()
    return admin
Ejemplo n.º 3
0
def db_init():
    """
    Initialize the DB
    """
    from lifemonitor.db import create_db, db
    logger.debug("Initializing DB...")
    create_db(settings=current_app.config)
    db.create_all()
    logger.info("DB initialized")
    # create a default admin user if not exists
    admin = User.find_by_username('admin')
    if not admin:
        admin = User('admin')
        admin.password = current_app.config["LIFEMONITOR_ADMIN_PASSWORD"]
        db.session.add(admin)
        db.session.commit()