Exemple #1
0
    def init(username, password):
        click.echo('initilize the database')
        db.create_all()
        admin = Admin.query.first()
        if admin is not None:
            click.echo("the administrator already exists, updating...")
            admin.username = username
            admin.set_password(password)
        else:
            click.echo("Creating the temporary adminstrator account")
            admin = Admin(username=username,
                          blog_title='Bluelog',
                          blog_sub_title="No, I'm the real thing.",
                          name='Admin',
                          about='Anything about you.')
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if category is None:
            click.echo("Creating the default category...")
            category = Category(name='Default')
            db.session.add(category)

        db.session.commit()
        click.echo('None')
Exemple #2
0
    def init(username, password):
        """Building Bluelog, just for you."""

        click.echo('Initializing the database...')
        db.create_all()

        admin = Admin.query.first()
        if admin is not None:
            click.echo('The administrator already exists, updating...')
            admin.username = username
            admin.set_password(password)
        else:
            click.echo('Creating the temporary administrator account...')
            admin = Admin(
                username="******",
                blog_title='ligewudi',
                blog_sub_title="cookie!",
                name='lyh',
                about="a little bit of niubi",
            )
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if category is None:
            click.echo('Creating the default category...')
            category = Category(name='Default')
            db.session.add(category)

        db.session.commit()
        click.echo('Done.')
Exemple #3
0
    def init(username, password):
        """Building Blog, just for you."""
        click.echo("Initializing the database...")
        db.create_all()

        admin = Admin.query.first()
        if admin:
            click.echo("The administrator already exists, updating... ")
            admin.username = username
            admin.set_password(password)
        else:
            click.echo("Creating the temporary administrator account...")
            admin = Admin(
                username=username,
                blog_title="Blog",
                blog_sub_title="No, I'm the real thing.",
                name="Admin",
                about="Anything about you.",
            )
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if not category:
            click.echo("Creating the default category... ")
            category = Category(name="Default")
            db.session.add(category)

        db.session.commit()
        click.echo("Done.")
Exemple #4
0
    def init(username, password):
        click.echo('初始化数据库...')
        db.create_all()

        admin = Admin.query.first()
        if admin is not None:  # 如果管理员已经存在就更新用户名和密码
            click.echo('管理员已经存在,正在更新...')
            admin.username = username
            admin.set_password(password)
        else:  # 否则,创建新管理员
            click.echo('创建临时管理员帐户...')
            admin = Admin(username="******",
                          blog_title="维度's Blog",
                          blog_sub_title="快乐生活,快乐编程!",
                          name="Gweid",
                          about="我,Gweid,一个小小的程序员...")
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if category is None:
            click.echo('创建默认分类...')
            category = Category(name='默认')
            db.session.add(category)

        db.session.commit()
        click.echo('完成')
Exemple #5
0
    def forge(category, post, comment):
        """
        生成虚拟数据
        :param category:
        :param post:
        :param comment:
        :return:
        """
        from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links

        db.drop_all()
        db.create_all()

        click.echo('Generating the administrator...')
        fake_admin()

        click.echo('Generating %d categories...' % category)
        fake_categories(category)

        click.echo('Generating %d posts...' % post)
        fake_posts(post)

        click.echo('Generating %d comments...' % comment)
        fake_comments(comment)

        click.echo('Generating links...')
        fake_links()

        click.echo('Done.')
Exemple #6
0
    def init(username, password):
        """Building MyBlog, just for you."""
        click.echo('Initializing the database...')
        db.create_all()

        admin = Admin.query.first()
        if admin:  # 如果数据库中已经有管理员记录就更新用户和密码
            click.echo('The administrator already exsists, updating...')
            admin.username = username
            admin.set_password(password)
        else:
            click.echo('Creating the temporary administrator account...')
            admin = Admin(username=username,
                          blog_title='MyBlog',
                          blog_sub_title="Discover the beauty everywhere.",
                          name='Admin',
                          about='Some things about you')
            admin.set_password(password)
            db.session.add(admin)

            category = Category.query.first()
            if category is None:
                click.echo('Creating the default category...')
                category = Category(name='default')
                db.session.add(category)

            db.session.commit()
            click.echo('Done.')
Exemple #7
0
 def initdb(drop):
     if drop:
         click.confirm('此操作将删除数据库,是否继续?', abort=True)
         db.drop_all()
         click.echo('删除表...')
     db.create_all()
     click.echo('初始化数据库...')
Exemple #8
0
    def init(username, password):
        """Building myblog, just for you."""

        click.echo('初始化数据库中...')
        db.create_all()

        admin = Admin.query.first()
        if admin is not None:
            click.echo('管理员已存在,更新管理员中...')
            admin.username = username
            admin.set_password(password)
        else:
            click.echo('新建一个管理员账号...')
            admin = Admin(
                username=username,
                blog_title='myblog',
            )
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if category is None:
            click.echo('正在新建一个默认分类...')
            category = Category(name='默认')
            db.session.add(category)

        db.session.commit()
        click.echo('已完成')
Exemple #9
0
    def init(username, password):
        """Building myblog, just for you."""

        click.echo('Initializing the database...')
        db.create_all()

        admin = Admin.query.first()
        if admin is not None:
            click.echo('The administrator already exists, updating...')
            admin.username = username
            admin.set_password(password)
        else:
            click.echo('Creating the temporary administrator account...')
            admin = Admin(
                username=username,
                blog_title='myblog',
                name='Admin',
            )
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if category is None:
            click.echo('Creating the default category...')
            category = Category(name='Default')
            db.session.add(category)

        db.session.commit()
        click.echo('Done.')
Exemple #10
0
    def forge(category, post, comment):
        """Generate fake data."""
        from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments

        db.drop_all()
        db.create_all()

        click.echo('正在创建管理员...')
        fake_admin()

        click.echo('正在创建 %d 个分类...' % category)
        fake_categories(category)

        click.echo('正在创建 %d 篇文章...' % post)
        fake_posts(post)

        click.echo('正在创建 %d 条评论...' % comment)
        fake_comments(comment)

        # click.echo('正在创建 %d 条二级评论...' % comment)
        # comments = Comment.query.all()
        # for comment in comments:
        #     fake_sub_comments(comment)

        click.echo('已完成')
Exemple #11
0
    def forge(category, post, comment):
        """Generates the fake categories, posts, comments and links."""
        from myblog.fakes import (
            fake_admin,
            fake_categories,
            fake_posts,
            fake_comments,
            fake_links,
        )

        db.drop_all()
        db.create_all()

        click.echo("Generating the administrator...")
        fake_admin()

        click.echo("Generating %d categories..." % category)
        fake_categories(category)

        click.echo("Generating %d posts..." % post)
        fake_posts(post)

        click.echo("Generating %d comments..." % comment)
        fake_comments(comment)

        click.echo("Generating links...")
        fake_links()

        click.echo("Done.")
Exemple #12
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.')
Exemple #13
0
 def initdb(drop):
     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('Initilize database')
Exemple #14
0
 def initdb(drop):
     if drop:
         click.confirm(
             'This operation will delete the database, do you want to continue?',
             abort=True)
         db.drop_all()
         click.echo("数据库已清空")
     db.create_all()
     click.echo("数据库初始化完成")
Exemple #15
0
 def initdb(drop):
     """Initialize the database."""
     if drop:
         click.confirm('此操作将会删除数据库,确认?', abort=True)
         click.echo('正在删除所有数据表')
         db.drop_all()
         click.echo('已删除所有数据表')
     click.echo('正在初始化数据库')
     db.create_all()
     click.echo('已初始化数据库')
Exemple #16
0
    def setUp(self):
        app = create_app('testing')
        self.context = app.test_request_context()
        self.context.push()
        self.client = app.test_client()
        self.runner = app.test_cli_runner()

        db.create_all()
        user = Admin(name='Grey Li', username='******', about='I am test', blog_title='Testlog', blog_sub_title='a test')
        user.set_password('123')
        db.session.add(user)
        db.session.commit()
Exemple #17
0
 def forge(category, post, comment):
     '''Generates the fake categories, posts and comments.'''
     db.drop_all()
     db.create_all()
     click.echo('Generating the administrator...')
     fake_admin()
     click.echo('Generating %d categories' % category)
     fake_categories(category)
     click.echo('Generating %d posts' % post)
     fake_posts(post)
     click.echo('Generating %d comments' % comment)
     fake_comments(comment)
     click.echo('done.')
Exemple #18
0
    def setUp(self) -> None:
        app = create_app("testing")
        self.context = app.test_request_context()
        self.context.push()
        self.client = app.test_client()
        self.runner = app.test_cli_runner()

        db.create_all()
        user = Admin(
            name="Grey Li",
            username="******",
            about="I am test",
            blog_title="Testlog",
            blog_sub_title="a test",
        )
        user.set_password("123")
        db.session.add(user)
        db.session.commit()
Exemple #19
0
    def forge(category, post, comment):
        from myblog.fakes import fake_admin, fake_categories, fake_comments, fake_posts
        db.drop_all()
        db.create_all()

        click.echo("生成管理员")
        fake_admin()

        click.echo("生成分类")
        fake_categories()

        click.echo("生成博文")
        fake_posts(post)

        click.echo("生成评论")
        fake_comments(comment)

        click.echo("生成完成")
Exemple #20
0
    def forge(category, post, comment):
        """Generate fake data."""
        from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments

        db.drop_all()
        db.create_all()

        click.echo('Generating the administrator...')
        fake_admin()

        click.echo('Generating %d categories...' % category)
        fake_categories(category)

        click.echo('Generating %d posts...' % post)
        fake_posts(post)

        click.echo('Generating %d comments...' % comment)
        fake_comments(comment)

        click.echo('Done.')
Exemple #21
0
    def forge(category, post, comment):
        from myblog.fakes import fake_posts, fake_comments, fake_categories, fake_admin, fake_links

        db.drop_all()
        db.create_all()
        click.echo('Generating the administrator...')
        fake_admin()

        click.echo("Generating %d categories..." % category)
        fake_categories(category)

        click.echo("Generating %d posts" % post)
        fake_posts(post)

        click.echo('Generating %d comments' % comment)
        fake_comments(comment)

        click.echo("Generating links")
        fake_links()

        click.echo("ok")
Exemple #22
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('Creating the categorys...')
        Math = Category(name="Math")
        Computer = Category(name="CS")
        Physics = Category(name="Physics")
        Life = Category(name="Life")

        db.session.add_all([Math, Computer, Physics, Life])
        db.session.commit()

        click.echo('Initialized databases.')
Exemple #23
0
    def forge(category, post, comment):
        from myblog.fakes import fake_admin, faker_categoryies, fake_posts, fake_comments, fake_links

        db.drop_all()
        db.create_all()

        click.echo('Generating the administrator...')
        fake_admin()

        click.echo('Generating {} categories...'.format(category))
        faker_categoryies(category)

        click.echo('Generating %d posts...' % post)
        fake_posts(post)

        click.echo('Generating %d comments...' % comment)
        fake_comments(comment)

        click.echo('Generating links...')
        fake_links()

        click.echo('Done.')
Exemple #24
0
    def forge(category, post, comment):
        """生成虚假数据。"""
        from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links

        db.drop_all()
        db.create_all()

        click.echo('生成管理员...')
        fake_admin()

        click.echo('生成 %d 个分类...' % category)
        fake_categories(category)  # 这里的category代表数量,下同

        click.echo('生成 %d 篇文章...' % post)
        fake_posts(post)

        click.echo('生成 %d 条评论...' % comment)
        fake_comments(comment)

        click.echo('生成分享链接...')
        fake_links()

        click.echo('完成')
Exemple #25
0
    def init(username, password):
        """
        注册管理员
        :param username:
        :param password:
        :return:
        """

        click.echo('Initializing the database...')
        db.create_all()

        admin = Admin.query.first()
        if admin is not None:
            click.echo('The administrator already exists, updating...')
            admin.username = username
            admin.set_password(password)
        else:
            click.echo('Creating the temporary administrator account...')
            admin = Admin(
                username=username,
                blog_title='Bluelog',
                blog_sub_title="No, I'm the real thing.",
                name='Admin',
                about='Anything about you.'
            )
            admin.set_password(password)
            db.session.add(admin)

        category = Category.query.first()
        if category is None:
            click.echo('Creating the default category...')
            category = Category(name='Default')
            db.session.add(category)

        db.session.commit()
        click.echo('Done.')