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})
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='删除失败')
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='用户认证失败')
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})
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)
def users(): return render_template('user.html', user_list=User.get_list())
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})
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})