def update_user(): uid = request.form.get('userid', '') userinfo_password = request.form.get('userinfo-password', '') manages_password = request.form.get('manager-password', '') userinfo_age = request.form.get('userinfo-age', '') _is_ok, _error = user.validate_update_user(uid, session['user']['username'], manages_password, userinfo_password, userinfo_age) if _is_ok: user.update_users(uid, userinfo_password, userinfo_age) return json.dumps({'is_ok': _is_ok, 'error': _error})
def update(): # 获取用户更新信息,username作为唯一标识符,且不能更新 params = request.args if request.method == 'GET' else request.form username = params.get('username', '') password = params.get('password', '') age = params.get('age', '') uid = request.args.get('uid', '') userinfo = request.args.get('userinfo', '') # 更新操作代码块 if user.validate_find(username): return render_template('updateUser.html', userinfo=userinfo, uid=uid, error=u'用户名存在,请重新输入') elif not username or not password or not age: return render_template('updateUser.html', userinfo=userinfo, uid=uid, error=u'(用户名、密码、年龄)不能为空,请重新输入') elif user.update_users(username=username, password=password, age=age, uid=uid): flash(u'更新用户信息成功') return redirect('/users/') else: return "用户更新失败!"
def update_users(event, context): print(event) user_id = auth.get_cookie_value(event['headers']) request_body = json.loads(event['body']) if 'id' not in request_body or request_body['id'] != user_id: body = {"message": "User not found"} response = { 'headers': { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': True, }, "statusCode": 400, "body": json.dumps(body) } return response body = user.update_users(request_body) response = { 'headers': { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': True, }, "statusCode": 200, "body": json.dumps(body) } return response
def update(): # 获取用户更新信息,username作为唯一标识符,且不能更新 username = request.args.get('username', '') age = request.form.get('age', '') password = request.form.get('password', '') # 更新操作代码块 if not username or not age or not password: return render_template('updateUser.html', error=u'(年龄、密码)不能为空,请重新输入') elif user.update_users(username=username, age=age, password=password): return redirect('/users/') else: return "用户更新失败!"
def update_user(): # 获取用户更新信息,username作为唯一标识符,且不能更新 params = request.args if request.method == 'GET' else request.form username = params.get('userinfo', '') password = params.get('password', '') age = params.get('age', '') uid = params.get('uid', '') # 更新操作代码块 _is_ok, _error = user.validate_update_user(username, password, age) if _is_ok: user.update_users(username=username, password=password, age=age, uid=uid) flash(u'更新用户信息成功') return redirect('/users/') else: return render_template('updateuser.html', userinfo=username, uid=uid, error=_error)
def user_update(): # 获取用户更新信息,username作为唯一标识符,且不能更新 username = request.args.get('username', '') age = request.form.get('age', '') job = request.form.get('job', '') password = request.form.get('password', '') # 更新操作代码块 if request.method == 'GET': # 用户信息回显 user_dict = user.get_user(username) return render_template('user_upd.html', username=username, user_dict=user_dict) else: if not username or not password: return render_template('user_upd.html', error=u'(密码)不能为空,请重新输入') elif user.update_users(username=username, age=age, password=password, job=job): return redirect('/user/list/') else: return "用户更新失败!"