Esempio n. 1
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=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.')
Esempio n. 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=username, is_admin=True)
            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='暂无')
        #     db.session.add(category)

        db.session.commit()
        click.echo('Done.')
Esempio n. 3
0
    def init(username, password):
        """Building Bluelog, just fot you"""
        click.echo('Initializing the database...')
        db.create_all()

        user = User.query.first()
        if user:
            click.echo('The administrator already exists, updating...')
            user.username = username
            user.password = password
        else:
            click.echo('Creating the temporary administrator account...')
            admin = User(username=username,
                         password=password,
                         blog_title='Bluelog',
                         blog_sub_title="No, I'm the real thing",
                         name='ZIO',
                         about='Any thing about ZIO',
                         email='*****@*****.**')
            # 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.')
Esempio n. 4
0
    def forge(category, tag, post, comment):
        """Generate fake data."""
        from bluelog.fakes import fake_admin, fake_categories, fake_tags, 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 tags...' % tag)
        fake_tags(tag)

        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.')
Esempio n. 5
0
    def forge(category, post, comment, channel, website):
        """Generate fake data."""
        from bluelog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links, fake_channels, fake_websites

        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)

        #lsc
        click.echo('Generating %d channels...' % channel)
        fake_channels(channel)
        #lsc
        click.echo('Generating %d websites...' % website)
        fake_websites(website)

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

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

        click.echo('Done.')
Esempio n. 6
0
    def forge(category, post, comment):
        '''生成虚拟数据'''
        from bluelog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links

        db.drop_all()
        db.create_all()

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

        click.echo(f'生成 {category} 个分类...')
        fake_categories(category)

        click.echo(f'生成 {post} 篇文章...')
        fake_posts(post)

        click.echo(f'生成 {comment} 条评论...')
        fake_comments(comment)

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

        if not os.path.exists(config['base'].CKEDITOR_UPLOAD_PATH):
            click.echo('图像上传路径不存在,创建中...')
            os.mkdir(config['base'].CKEDITOR_UPLOAD_PATH)

        click.echo('完成')
Esempio n. 7
0
    def init(username, password):
        """初始化博客"""
        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_sub_title="做真实的自己",
                          name='Admin',
                          about='关于我的一些事情。')
            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='默认')
            db.session.add(category)

        db.session.commit()
        click.echo('Done.')
Esempio n. 8
0
    def init(username, password):
        """创建博客为了你"""

        click.echo("正在初始化数据库")
        db.create_all()

        admin = Admin.query.first()
        if admin:  # 如果数据库中已经有管理员记录就更新用户名和密码
            click.echo('管理员已存在,正在更新...')
            admin.username = username
            admin.set_password(password)
        else:  # 否则创建新的管理员记录
            click.echo('正在创建管理员记录')
            admin = Admin(username=username,
                          blog_title='博客',
                          blog_sub_title='我才是最受欢迎的',
                          name='管理员',
                          about='新手上路,请多多关注')
            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('完成')
Esempio n. 9
0
    def init(username, password):
        '''初始化博客'''

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

        click.echo('创建管理员账户...')
        admin = Admin(username=username,
                      blog_title=f'{username.capitalize()}的博客',
                      blog_sub_title='天涯路远 | 见字如面',
                      name=username.capitalize(),
                      about=username.capitalize() + '...')
        admin.set_password(password)
        db.session.add(admin)

        click.echo('创建默认分类...')
        category = Category(name='默认分类')
        db.session.add(category)

        db.session.commit()

        if not os.path.exists(config['base'].CKEDITOR_UPLOAD_PATH):
            click.echo('图像上传路径不存在,创建中...')
            os.mkdir(config['base'].CKEDITOR_UPLOAD_PATH)

        click.echo('完成')
Esempio n. 10
0
 def initdb(drop):
     if drop:
         click.confirm('删除存在的数据库和数据?', abort=True)
         db.drop_all()
         click.echo('数据库数据删除完成')
     db.create_all()
     click.echo("数据库创建完成")
Esempio n. 11
0
 def initdb(drop):
     if drop:
         click.confirm('这会删除数据库,确定继续吗?', abort=True)
         db.drop_all()
         click.echo('删除数据库')
     db.create_all()
     click.echo("数据库初始化完成")
Esempio n. 12
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=username,
                blog_title='xw.cai个人博客',
                blog_sub_title=
                "You have to survive the days when nobody cares about it "
                "before you can embrace your poetry and the distance.",
                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.')
Esempio n. 13
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=username,
                blog_title='博客',
                blog_sub_title='小小博客,容纳天地~',
                name='沧海一刀断银河',
                about='醉侠骨柔情',
            )
            admin.set_password(password)
            db.session.add(admin)

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

        db.session.commit()
        click.echo("初始化完成")
Esempio n. 14
0
    def init(username, password):
        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='I am the sub_title',
                name='Admin',
                about='keep moving, keep study'
            )
            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')
Esempio n. 15
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('Initialized database.')
Esempio n. 16
0
    def forge():
        # 下面的这两句代码是必须的
        db.drop_all()
        db.create_all()

        from tests.datas import companys
        from tests.datas import phones

        for key, value in companys.items():
            company = Company(name=key, location=value)
            db.session.add(company)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
        click.echo('写入公司信息成功...')
        for phone in phones:
            phone = Phone(id=phone[0],
                          model=phone[1],
                          price=phone[3],
                          company_name=phone[2])
            db.session.add(phone)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
        click.echo('写入电话信息成功...')

        phone = Phone(id=7, model='Blackberry', price=5987, company_name='RIM')
        db.session.add(phone)
        db.session.commit()
Esempio n. 17
0
    def forge(category, post, comment):
        """Generate fake data."""
        from bluelog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links

        click.echo('dropping old database...')
        db.drop_all()
        click.echo('creating new database...')
        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.')
Esempio n. 18
0
 def initdb(drop):
     if drop:
         click.confirm('Confirm to delete the database?', abort=True)
         db.drop_all()
         click.echo('Deleted database')
     db.create_all()
     click.echo('Initialized database')
Esempio n. 19
0
    def forge(category, post, comment, url):
        """Generates the fake categories, posts, and comments.

        生成假数据用于展示效果。

        Args:
            category:生成分类数量,默认为10
            post:生成文章数量,默认为50
            comment:生成评论数量,默认为500
            url:生成链接数量,默认为5

        """
        from bluelog.fakes import (fake_admin, fake_categories, fake_posts,
                                   fake_comments, fake_url)

        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('Gemerating %d comments..' % comment)
        fake_comments(comment)

        click.echo('Generating %d urls..' % url)
        fake_url(url)

        click.echo('Done.')
Esempio n. 20
0
    def init(username, password):
        """Building Bluelog, 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='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('创建默认分类...')
            category = Category(name='Default')
            db.session.add(category)

        db.session.commit()
        click.echo('完成.')
Esempio n. 21
0
 def initdb(drop):
     """Initialize the database."""
     if drop:
         click.confirm('此操作将删除数据库, 你确定要继续吗?', abort=True)
         db.drop_all()
         click.echo('删除表.')
     db.create_all()
     click.echo('初始化数据库.')
Esempio n. 22
0
 def forge(category, post, comment):
     """Generate the fake categories,posts,comments."""
     db.drop_all()
     db.create_all()
     click.echo('Generating the administrator...')
     fake_admin()
     click.echo(f'Generating {category} categories...')
     fake_categories(category)
     click.echo(f'Generating {post} posts...')
     fake_post(post)
     click.echo(f'Generating {comment} comment...')
     fake_comments(comment)
     click.echo('Done.')
Esempio n. 23
0
 def forge(category, post, comment):
     """Generates the fake categories, posts, and comments."""
     from bluelog.fakes import fake_categories,fake_posts,fake_comments, fake_admim
     db.drop_all()
     db.create_all()
     click.echo('Generating the administrator...')
     fake_admim()
     click.echo('Generating %d categories...'% category)
     fake_categories()
     click.echo('Generating %d posts...' % post)
     fake_posts()
     click.echo('Generating %d comments...' % comment)
     fake_comments()
     click.echo('Done.')
Esempio n. 24
0
    def initdb(drop):
        """Initialize the database.

        Args:
            drop: 可选参数,如果为True,则删除数据库中的数据
        """
        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.')
Esempio n. 25
0
    def setUp(self):
        app = create_app('bluelog')
        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()
Esempio n. 26
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(username='******',
                     blog_title='Testlog',
                     blog_sub_title='Test Sub Title',
                     name='Jeremy Lin',
                     about='Test About')
        user.set_password('12345678')  # LoginForm: password -> length(8, 128)
        db.session.add(user)
        db.session.commit()
Esempio n. 27
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()
        user.username = '******'
        user.name = '詹姆斯'
        user.about = '我是一个测试账号'
        user.blog_title = '测试账号'
        user.blog_sub_title = '测试'
        user.set_password('1234')
        db.session.add(user)
        db.session.commit()
Esempio n. 28
0
    def forge(article, comment):
        """Generate fake data."""
        from bluelog.fakes import fake_blogger, fake_articles, fake_comments

        db.drop_all()
        db.create_all()

        click.echo('Generating the blogger...')
        fake_blogger()

        click.echo('Generating %d categories...' % article)
        fake_articles(article)

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

        click.echo('Done.')
Esempio n. 29
0
    def forge(category, post):
        """Generate fake data."""
        from bluelog.fakes import fake_admin, fake_categories, fake_posts

        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('Done.')
Esempio n. 30
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 = My_Admin( 
            username = '******',
            blog_title = 'It is a test',
            blog_sub_title = 'Test',
            name = 'Ma',
            about = 'Test this programme'
         )
        user.set_password('123')
        db.session.add(user)
        db.session.commit()