def user_delete(): perams = request.args if request.method == 'GET' else request.form uid = perams.get('uid','') _user = user.get_user_by_id(uid=uid)[0] if user.user_delete(_user['id']): flash(u'删除: %s成功' % _user['username']) return redirect('/user/list/') else: return '用户删除失败.'
def user_update(): perams = request.args if request.method == 'GET' else request.form uid = perams.get('uid', '') # passwd = perams.get('passwd','') age = perams.get('age', '') job = perams.get('job', '') _user = user.get_user_by_id(uid=uid)[0] if request.method == 'GET': return render_template('user_update.html', _user=_user) if user.user_update(uid, age, job): flash(u'更新: %s成功' % _user['username']) return redirect('/user/list/') else: return '用户更新失败.'
def user_update(): perams = request.args if request.method == 'GET' else request.form uid = perams.get('uid', '') age = perams.get('age', '') job = perams.get('job', '') _user = user.get_user_by_id(uid=uid)[0] if request.method == 'GET': return json.dumps(_user) else: #1、验证用户数据合法性; _is_ok, error = user.vilidate_update_user(uid=uid, age=age, job=job) if _is_ok: # 2、如果合法,入库; flash(u'更新: %s成功' % _user['username']) user.user_update(uid, age, job) return json.dumps({'is_ok': _is_ok, 'error': error})
def user_update(): perams = request.args if request.method == 'GET' else request.form uid = perams.get('uid','') age = perams.get('age','') job = perams.get('job','') _user = user.get_user_by_id(uid=uid)[0] if request.method=='GET': return render_template("user_update.html",_user=_user) if user.user_update(uid=uid, age=age, job=job): flash(u'更新:%s成功' % _user['username']) return redirect('/user/list/') if str(job) ==_user['job'] and int(age) ==_user['age']: flash(u'更新:%s成功' % _user['username']) return redirect('/user/list/') else: print uid,age,job,_user['job'],_user['age'] return '用户更新失败'
def user_update(): perams = request.args if request.method == 'GET' else request.form uid = perams.get('uid', '') # passwd = perams.get('passwd','') age = perams.get('age', '') job = perams.get('job', '') _user = user.get_user_by_id(uid=uid)[0] if request.method == 'GET': return render_template('user/user_update.html', _user=_user) if user.user_update(uid, age, job): # flash(u'更新: %s成功' %_user['username']) # return redirect('/user/list/') return json.dumps({ "is_ok": True, "msg": u"更新%s成功" % _user['username'] }) else: # return '用户更新失败.' return json.dumps({ "is_ok": False, "msg": u"更新%s失败" % _user['username'] })