Esempio n. 1
0
def db_create():
    """create db's schema, create first/admin user
    alembic (0.8.3) can't support sqlite for upgrade:
    (NotImplementedError: No support for ALTER of constraints in SQLite dialect)"""

    db.create_all()

    print('create admin user...')
    user = create_new_user_with_default_password()
    if user is None:
        return

    db.session.add(user)
    db.session.commit()
    return
Esempio n. 2
0
def db_add_site():
    """create first site, first blog and page; config admin user"""
    from rpress.models import User

    print('create site...')
    site_domain_name = prompt('site domain')

    print('site admin user name...')
    user_name = ask_user_name()
    user = User.query.filter_by(name=user_name).first()
    if user is None:
        user = create_new_user_with_default_password(user_name)
        if user is None:
            print('error!!')
            return

    add_site_sample_data(db_session=db.session, site_domain=site_domain_name, admin_user=user)
    db.session.commit()
    return