Exemplo n.º 1
0
    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.')
Exemplo n.º 2
0
    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.')
Exemplo n.º 3
0
    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.')
Exemplo n.º 4
0
 def initdb(drop):
     if drop:
         click.confirm('该选项将会删除数据库,是否继续执行?', abort=True)
         db.drop_all()
         click.echo('删除数据库')
     db.create_all()
     click.echo('初始化数据库')
Exemplo n.º 5
0
    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.')
Exemplo n.º 6
0
 def initdb(drop):
     if drop:
         click.confirm('Confirm to delete database')
         db.drop_all()
         click.echo('Database deleted')
     db.create_all()
     click.echo('Initialized database')
Exemplo n.º 7
0
 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.')
Exemplo n.º 8
0
    def init():
        click.echo("creating database and tables...")
        db.drop_all()
        db.create_all()

        click.echo("Initializing the roles and permission...")
        Role.init_role()

        click.echo("Done...")
Exemplo n.º 9
0
 def initdb(drop):
     '''Initialize the database'''
     if drop:
         click.confirm('The operation will delete the database, '
                       'will you like to continue?', abort=True)
         db.drop_all()
         click.echo('Drop tables.')
     db.create_all()
     click.echo('Initialized the database.')
Exemplo n.º 10
0
    def initdb(drop):
        """
		使用flask initdb清空数据库然后再初始化数据库
		"""
        if drop:
            click.confirm('该操作将会清空数据表数据,是否继续?', abort=True)
            db.drop_all()
            click.echo('Drop tables.')
        db.create_all()
        click.echo('Initialized database.')
Exemplo n.º 11
0
    def init():
        """Initialize Albumy."""
        click.echo('Droping the database...')
        db.drop_all()
        click.echo('Initializing the database...')
        db.create_all()

        click.echo('Initializing the roles and permissions...')
        Role.init_role()

        click.echo('Done.')
Exemplo n.º 12
0
    def forge(user):
        """Generate fake data."""

        from albumy.fakes import fake_admin, fake_user

        db.drop_all()
        db.create_all()

        click.echo('Generating the administrator...')
        fake_admin()
        click.echo('Generating %d users...' % user)
        fake_user(user)
        click.echo('Done.')
Exemplo n.º 13
0
    def init(drop):
        """Initialize Albumy."""
        if drop:
            click.confirm(
                'This operation will delete the database, do you want to continue?',
                abort=True)
            db.drop_all()
            click.echo('Drop tables.')
        click.echo('Initializing the database...')
        db.create_all()

        click.echo('Initializing the roles and permissions...')
        Role.init_role()

        click.echo('Done.')
Exemplo n.º 14
0
    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')
Exemplo n.º 15
0
    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.')
Exemplo n.º 16
0
 def tearDown(self):
     db.drop_all()
     self.context.pop()
Exemplo n.º 17
0
 def init_db():
     db.drop_all()
     db.create_all()
Exemplo n.º 18
0
 def setUp(self):
     super(CLITestCase, self).setUp()
     db.drop_all()