示例#1
0
def change_passwd():
    params = request.args if request.method == 'GET' else request.form
    uid = params.get('userid')
    upass = params.get('user-password')
    muser = session['username']['username']
    mpass = params.get('manager-password')
    _is_ok, _error = User.valid_change_passwd(uid, upass, muser, mpass)
    if _is_ok:
        _is_ok, _error = User.change_passwd(uid, upass)
    return jsonify({'is_ok': _is_ok, 'error': _error})
示例#2
0
def user_del():
    params = request.args if request.method == 'GET' else request.form
    id = params.get('id')
    username = params.get('username')
    if User.user_del(int(id), username):
        # flash("用户删除成功")
        return redirect('/user/')
    return render_template('user.html', error='删除失败')
示例#3
0
def login():
    params = request.args if request.method == 'GET' else request.form
    username = params.get('username', '')
    password = params.get('password', '')
    #类调用--------
    get_session = User.validate_login(username, password)
    if get_session:
        session['username'] = get_session
        return redirect('/user/')
    else:
        return render_template('login.html', username=username, error='用户认证失败')
示例#4
0
def assets__concmd():
    params = request.args if request.method == 'GET' else request.form
    _is_ok, _result = User.validate_mpass(params)
    if _is_ok:
        error = ''
        _data = []
        nums = 1
        for x in _result:
            if x[0]:
                _data += (nums, x[0])
            else:
                _data += (nums, x[1])
            nums += 1
    elif _result:
        error = _result
        _data = ''
    else:
        error = '执行失败'
        _data = ''
    return jsonify({'is_ok': _is_ok, 'error': error, 'data_result': _data})
示例#5
0
def users_add():
    params = request.args if request.method == 'GET' else request.form
    if not params:
        return render_template('useradd.html')
    '''
    username = params.get('username')
    password = params.get('password')
    gender = params.get('gender')
    hobby = params.getlist('hobby')
    department = params.get('department')
    filename = request.files.get('files')
    if filename:
        print filename.filename
        filename.save('/tmp/aa.txt')
    age = params.get('age')
    telphone = params.get('telphone')
    email = params.get('email')
    '''
    if User.user_add(params):
        # flash("用户%s添加成功" % username)
        return redirect('/user/')
    else:
        error = '用户名已存在'
    return render_template('useradd.html', error=error)
示例#6
0
def users():
    return render_template('user.html', user_list=User.get_list())
示例#7
0
def newuser():
    params = request.args if request.method == 'GET' else request.form
    _is_ok, _error = User.user_add(params)
    return jsonify({'is_ok': _is_ok, 'error': _error})
示例#8
0
def user_reset():
    params = request.args if request.method == 'GET' else request.form
    id = params.get('id')
    username = params.get('username')
    _is_ok, _error, newpasswd = User.user_reset(id, username)
    return jsonify({'is_ok': _is_ok, 'error': _error, 'newpass': newpasswd})