def forge(user, follow, photo, tag, collect, comment): """Generate fake data.""" from albumy.fakes import fake_admin, fake_comment, fake_follow, fake_photo, fake_tag, fake_user, fake_collect db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_user(user) click.echo('Generating %d follows...' % follow) fake_follow(follow) click.echo('Generating %d tags...' % tag) fake_tag(tag) click.echo('Generating %d photos...' % photo) fake_photo(photo) click.echo('Generating %d collects...' % photo) fake_collect(collect) click.echo('Generating %d comments...' % comment) fake_comment(comment) click.echo('Done.')
def forge(user, follow, photo, tag, collect, comment): from albumy.fakes import fake_admin, fake_user, fake_photo, fake_tag, fake_comment, fake_collect, fake_follow db.drop_all() db.create_all() click.echo('Initializing the role and permissions...') Role.init_role() click.echo('Generating the administrator') fake_admin() click.echo(f'Generating {user} users...') fake_user(user) click.echo(f'Gnerrating {follow} follows...') fake_follow(follow) click.echo(f'Generating {tag} tags...') fake_tag(tag) click.echo(f'Generating {photo} photos...') fake_photo(photo) click.echo(f'Generating {collect} collects..') fake_collect(collect) click.echo(f'Generating {comment} comments...') fake_comment(comment) click.echo('Done.')
def forge(user, follow, photo, tag, collect, comment, category, post): """Generate fake data.""" from albumy.fakes import fake_admin, fake_comment, fake_follow, fake_photo, fake_tag, fake_user, fake_collect, \ fake_categories, fake_posts # 把这两句注释掉,曾在这里犯下惨痛的教训 执行flask forge # db.drop_all() # db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_user(user) click.echo('Generating %d follows...' % follow) fake_follow(follow) click.echo('Generating %d tags...' % tag) fake_tag(tag) click.echo('Generating %d photos...' % photo) fake_photo(photo) click.echo('Generating %d collects...' % photo) fake_collect(collect) click.echo('Generating %d comments...' % comment) fake_comment(comment) click.echo('Generating %d categories...' % category) fake_categories(category) click.echo('Generating %d posts...' % post) fake_posts(post) click.echo('Done.')
def forge(user, tag, photo, collect, comment, follow, notification): """Generate fake data.""" db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_user(user) click.echo('Generating %d follows...' % follow) fake_follow(follow) click.echo('Generating %d tags...' % tag) fake_tag(tag) click.echo('Generating %d photos...' % photo) fake_photo(photo) click.echo('Generating %d collects...' % collect) fake_collect(collect) click.echo('Generating %d comments...' % comment) fake_comment(comment) click.echo('Generating %d notifications...' % notification) fake_notification(notification) click.echo('Done.')
def fake(user, follow, photo, tag, collect, comment): """ 使用flask fake创建虚拟数据 """ from albumy.fakes import fake_admin, fake_comment, fake_follow, fake_photo, fake_tag, fake_user, fake_collect db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') # 添加管理员账号 fake_admin() click.echo('Generating %d users...' % user) # 随机用户数据 fake_user(user) click.echo('Generating %d follows...' % follow) # 虚拟关注数据 fake_follow(follow) click.echo('Generating %d tags...' % tag) # 虚拟标签 fake_tag(tag) click.echo('Generating %d photos...' % photo) # 虚拟图片 fake_photo(photo) click.echo('Generating %d collects...' % photo) # 随机收藏数据 fake_collect(collect) click.echo('Generating %d comments...' % comment) # 虚拟评论 fake_comment(comment) click.echo('Done.')
def forge(user): from albumy.fakes import fake_admin, fake_users db.drop_all() db.create_all() Role.init_role() fake_admin() fake_users(user) fake_tag() fake_photo() fake_comment() fake_collect() fake_follow() click.echo('Done')
def forge(user, photo, tag, comment, collect, follow): """Generate fake data.""" from albumy.fakes import fake_user, fake_admin, fake_tag, fake_photo, fake_comment, fake_collect, fake_follow from flask import current_app uploads_path = current_app.config['ALBUMY_UPLOAD_PATH'] avatars_path = current_app.config['AVATARS_SAVE_PATH'] for f in os.listdir(uploads_path): filepath = os.path.join(uploads_path, f) if os.path.isfile(filepath): os.remove(filepath) print('delete uploads file {}'.format(f)) for f in os.listdir(avatars_path): filepath = os.path.join(avatars_path, f) if os.path.isfile(filepath): os.remove(filepath) print('delete uploads file {}'.format(f)) click.echo('drop tables and then create...') db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_user(user) click.echo('Generating %d tags...' % tag) fake_tag() click.echo('Generating %d photos...' % photo) fake_photo(photo) click.echo('Generating %d comments...' % comment) fake_comment(comment) click.echo('Generating %d collects...' % collect) fake_collect(collect) click.echo('Generating %d follows...' % follow) fake_follow(follow) click.echo('Done.')
def forge(user, tag, photo, comment, collect, follow): from albumy.fakes import fake_admin, fake_user, fake_photo, fake_comment, fake_collect, fake_tag, fake_follow db.drop_all() db.create_all() click.echo('初始化角色和权限') Role.init_role() click.echo('创建管理员') fake_admin() click.echo('生成用户') fake_user(user) click.echo('生成关注关系') fake_follow(follow) click.echo('生成标签') fake_tag(tag) click.echo('生成照片。。。') fake_photo(photo) click.echo('生成评论') fake_comment(comment) click.echo('生成收藏') fake_collect(collect) click.echo('ok')