예제 #1
0
def create_db():  # 第二课新增
    """
    Recreates a local database. You probably should not use this on
    production.
    """
    db.create_all()
    db.session.commit()
    Role.insert_roles()
예제 #2
0
def user_list():  #第五课新增
    Role.insert_roles()
    username = session.get('username')
    role = session.get('role_id')
    user_list = User.query.outerjoin(Role, User.role_id == Role.id).all()
    return layout('/account/users.html',
                  users=user_list,
                  id=role,
                  user=username)
예제 #3
0
파일: views.py 프로젝트: zhanzq/myproject
def register():   # 第二课增加内容
    Role.insert_roles()
    if request.method == 'POST':
        try:
            form = request.form
            user = User(username=form['username'], email=form['email'], password=form['password'])
            db.session.add(user)
            db.session.commit()
            return redirect(url_for(request.args.get('next') or 'live.login'))
        except Exception as e:
            print(e)
            abort(403)
    return render_template('/live/register.html')
예제 #4
0
def login():  #第三课内容
    Role.insert_roles()
    if request.method == "POST":
        from backend.account.logic import login_logic
        result = login_logic(request.form)
        if result['RETURN_CODE'] == 'S':
            flash(result['RETURN_DESC'], 'success')

            if '?' in str(request.referrer) and 'cburl' in str(
                    request.referrer).split('?')[1]:
                cburl = str(request.referrer).split('?')[1].split('=')[1]
                return redirect(cburl, 302)
            return redirect(url_for('admin.index'))
        else:
            flash(result['RETURN_DESC'], 'danger')

    return render_template('/account/login.html')
예제 #5
0
파일: views.py 프로젝트: suliuer/myproject
def user_list():  #第五课新增
    Role.insert_roles()
    user_list = User.query.outerjoin(Role, User.role_id == Role.id).all()
    return layout('/account/users.html', users=user_list)