def init(password): """Initialize Blogs.""" click.echo('Initializing the database...') db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Initializing the status...') Status.init_status() click.echo('Initializing the series...') Series.init_series() admin = User.query.first() if admin is not None: click.echo('The administrator already exists, updating...') admin.set_password(password) else: click.echo('Creating the temporary administrator account...') admin = User(email=app.config['ADMIN_EMAIL'], username='******', confirmed=True) admin.set_password(password) db.session.add(admin) db.session.commit() click.echo('Done.')
def initdb(drop): """Initialize the database.""" if drop: click.confirm('This operation will delete the database, do you want to continue?', abort=True) db.drop_all() click.echo('Drop tables.') db.create_all() click.echo('Initialized database.')
def initdb(drop): """Initialize the database.""" if drop: click.confirm('你确定要删除之前的数据库吗?', abort=True) db.drop_all() click.echo('删除数据库.') db.create_all() click.echo('成功建立数据库.')
def forge(category, post, comment): from blogs.fakes import fake_admin, fake_category, fake_posts, fake_comments, fake_links db.drop_all() db.create_all() click.echo('生成超级用户...') fake_admin() click.echo('分类列表...') fake_category(category) click.echo('生成文章信息...') fake_posts(post) click.echo('生成评论信息...') fake_comments(comment) click.echo('生成友情链接...') fake_links() click.echo('完成.')
def forge(topic, user, post, collect, group): """Generate fake data.""" from blogs.fakes import fake_admin, fake_topics, fake_users, fake_posts, fake_groups, \ fake_collect db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Initializing the status...') Status.init_status() click.echo('Initializing the series...') Series.init_series() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_users(user) click.echo('Generating %d groups...' % group) fake_groups(group) click.echo('Generating %d topics...' % topic) fake_topics(topic) click.echo('Generating %d posts...' % post) fake_posts(post) click.echo('Generating %d collects...' % collect) fake_collect(collect) click.echo('Done')