Example #1
0
 def init(username, password):
     click.echo('Initializing the database...')
     db.create_all()
     admin = Admin.query.first()
     if admin:
         click.echo('The admin already exists, updating...')
         admin.username = username
         admin.set_password(password)
     else:
         click.echo('Creating the temporary admin account...')
         admin = Admin(
             username='******',
             name='Xiaozekun',
             about='Python开发',
             blog_title='LIHFTS',
             blog_sub_title='lihfts'
         )
         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')
Example #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,
                          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.')
Example #3
0
def fake_admin():
    admin = Admin(username='******',
                  blog_title='Blog',
                  blog_sub_title='No, I\'m the real thing.',
                  name='zhaoxinbo',
                  about='Um, zhaoxinbo sanzhandeng')
    admin.set_password('helloflask')  #生成默认密码
    db.session.add(admin)
    db.session.commit()
Example #4
0
def fake_admin():
    admin = Admin(username='******',
                  blog_title='Home',
                  blog_sub_title='I can you can too',
                  name='Arvine',
                  about='I\'am on my way.')
    admin.password = '******'
    db.session.add(admin)
    db.session.commit()
Example #5
0
def fake_admin():
    db.create_all()
    admin = Admin(username='******',
                  name='Xiaozekun',
                  about='编程工程师',
                  blog_title='我的BLOG',
                  blog_sub_title='lihfts,hhhhhhh')
    admin.set_password('1q2w3e4t5r')
    db.session.add(admin)
    db.session.commit()
Example #6
0
def fake_admin():
    admin = Admin(
        username='******',
        blog_title='Luobo blog',
        blog_sub_title="No,i'm the real thing.",
        name='Mima Kirigoe',
        about='Um, l, Mima Kirigoe, had a fun time as a member of CHAM...'
    )
    admin.set_password('helloflask')
    db.session.add(admin)
    db.session.commit()
Example #7
0
def fake_admin():
    admin = Admin(
        username = '******' ,
        blog_title = '博客' ,
        blog_sub_title = '这里还没有什么简介',
        name = '何翱翔',
        about = '这是我的一个flask练习小项目!'
    )
    admin.password_hash='123456'
    db.session.add(admin)
    db.session.commit()
Example #8
0
def fake_admin():
    admin = Admin(
        username='******',
        blog_title='Bluelog',
        blog_sub_title="No, I'm the real thing.",
        name='Ted Duan',
        about='Um, l, Ted Duan, had a fun time as a member of CHAM...'
    )
    admin.set_password('helloblog')
    db.session.add(admin)
    db.session.commit()
Example #9
0
File: base.py Project: zxbylx/blog
    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()
Example #10
0
def register():
    return abort(404)
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        us = Admin.objects(username=username)
        if us:
            flash("Username already taken.")
            return redirect(url_for('register'))

        hash_pass = hashlib.sha512(password).hexdigest()
        u = Admin(username, hash_pass)
        u.save()
        session['logged_in'] = True
        flash('You successfully made an account.')
        return redirect(url_for('home'))

    return render_template('register.html')
Example #11
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,
            name='Admin',
        )
        admin.set_password(password)
        db.session.add(admin)
    db.session.commit()
    click.echo('Done.')
Example #12
0
    def init(username, password):

        click.echo('Initializing...')
        

        admin = Admin.query.first()
        if admin is not None:
            admin.username = username
            admin.set_password(password)
        
        else:
            admin = Admin(username=username, 
                          name='Admin', 
                          site_title="Jason's site", about="")
            admin.set_password(password)
            db.session.add(admin)

        if Category.query.first() is None:
            category = Category(name='Default')
            db.session.add(category)
        
        db.session.commit()
Example #13
0
    def init(username, password):
        click.echo('Initializing the database...')
        db.create_all()

        admin = Admin.query.first()
        if admin:
            admin.username = username
            admin.password = password
        else:
            admin = Admin(username=username,
                          blog_title='Home',
                          blog_sub_title='I can you can too',
                          name='Arvine',
                          about='I\'am on my way.')
            admin.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.')
Example #14
0
def do_login():
    if request.method == 'POST':
        passwd = request.form['passwd']

        if passwd:
            hashed_passwd = md5(passwd).hexdigest()  # md5(passwd)
            hashed_passwd_from_db = Admin.getone().passwd

            if hashed_passwd == hashed_passwd_from_db:
                session[SESSION_KEY] = 1
                flashx.success('Logged in successfully')
                return redirect(url_for('admin'))
            else:
                flashx.error('Incorrect password')
        else:
            flashx.warning('Empty input')
    return redirect(url_for('login'))
Example #15
0
def update_password():
    password_now = request.form['password_now']
    password_new = request.form['password_new']
    password_new_repeat = request.form['password_new_repeat']

    if password_now and password_new and password_new_repeat:
        if password_new_repeat != password_new:
            flashx.warning('The two new passwords do not match')
        else:
            admin = Admin.getone()

            hashed_passwd_now = md5(password_now).hexdigest()

            if hashed_passwd_now != admin.passwd:
                flashx.warning('Incorrect password')
            else:
                admin.passwd = md5(password_new).hexdigest()
                admin.save()
                flashx.success('Save password successfully, please login again')
                return redirect(url_for('logout'))
    else:
        flashx.warning('Empty input!')
    return redirect(url_for('password'))
def fake_admin():
    admin = Admin(
        username = '******',
        name = 'Jason',
        about = 'This is my first personal blog which is created by Junhao and Yihua. \
                    I will share my stories and some articles in this blog.',
        site_title = "Jason's Personal blog"
    )
    admin.set_password('fullstack')
    db.session.add(admin)
    db.session.commit()

    bio = Bio(
        name = 'Jason Gale',
        intro = 'Donec quam felis, ultricies nec, pellentesque eu. \
             Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
                  Aenean commodo ligula eget dolor. Aenean massa. \
                      Cum sociis natoque penatibus et magnis dis parturient montes, \
                          nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.\
                               Maecenas nec odio et ante tincidunt tempus.\
                           Donec vitae sapien ut libero venenatis faucibus.\
                                Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh.',
        current_job = 'Software Engineer'


    )

    db.session.add(bio)
    db.session.commit()

    work = Work_(
        title = 'Senior Software Engineer',
        abstract = 'Role description goes here ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.\
             Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Donec pede justo,\
             fringilla vel. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. \
                 Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis.',
        time = '2018-present',
        company = 'Google'
    )
    db.session.add(work)
    db.session.commit()

    project = Project(
        title = 'Senior Software Engineer',
        abstract = 'Role description goes here ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.\
             Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Donec pede justo,\
             fringilla vel. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. \
                 Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis.',
        
        role = 'Leader'
    )
    db.session.add(project)
    db.session.commit()

    skill_1 = Skill(
        content = 'JavaScript/Angular/React/Vue',
        is_techical = True
    )
    skill_2 = Skill(
        content = 'Python/Ruby/PHP',
        is_techical = True
    )
    skill_3 = Skill(
        content = 'Effective communication',
        is_techical = False
    )

    db.session.add(skill_1)
    db.session.add(skill_2)
    db.session.add(skill_3)
    db.session.commit()