Beispiel #1
0
def init_db():
    import string
    import random
    from flask.ext.security.utils import encrypt_password
    from model.create_db import db
    from model.security import User, Role
    import model.blog
    from controllers.security import user_datastore, security

    app.config['SQLALCHEMY_ECHO'] = True
    db.init_app(app)
    security.init_app(app)
    db.drop_all()
    db.create_all()

    user_role = Role(name='user')
    super_user_role = Role(name='superuser')
    db.session.add(user_role)
    db.session.add(super_user_role)
    db.session.commit()

    user_datastore.create_user(first_name='Admin',
                               email='admin',
                               password=encrypt_password('admin'),
                               roles=[user_role, super_user_role])

    db.session.commit()
Beispiel #2
0
def init_db():
    import string
    import random
    from flask.ext.security.utils import encrypt_password
    from model.create_db import db
    from model.security import User, Role
    import model.blog
    from controllers.security import user_datastore, security

    app.config["SQLALCHEMY_ECHO"] = True
    db.init_app(app)
    security.init_app(app)
    db.drop_all()
    db.create_all()

    user_role = Role(name="user")
    super_user_role = Role(name="superuser")
    db.session.add(user_role)
    db.session.add(super_user_role)
    db.session.commit()

    user_datastore.create_user(
        first_name="Admin", email="admin", password=encrypt_password("admin"), roles=[user_role, super_user_role]
    )

    db.session.commit()
Beispiel #3
0
def drop_db():
    from model.create_db import db

    db.init_app(app)
    db.drop_all()
Beispiel #4
0
def drop_db():
    from model.create_db import db

    db.init_app(app)
    db.drop_all()