def update(): if not session.get('name', None): return redirect('login.html') if request.method == "POST": data = dict(request.form) condition = ["%s='%s'" % (k, v[0]) for k, v in data.items()] try: user_db.update(condition, data['id'][0]) return redirect('/userlist') except: errmsg = "update user failed" print traceback.print_exc() return render_template("update.html", result=errmsg) else: id = request.args.get('id') fields = ['id', 'name', 'name_cn', 'email', 'mobile'] try: res = user_db.selectId(fields, id) user = dict((k, res[i]) for i, k in enumerate(fields)) return render_template('update.html', user=user) except: errmsg = "select userinfo failed" print traceback.print_exc() return render_template("update.html", result=errmsg)
def updateidc(): table = 'idc' if not session.get('name',None): return redirect('/login') if request.method == "POST": data = dict(request.form) print data print data['id'][0] condition = [ "%s='%s'" % (k,v[0]) for k,v in data.items() ] print condition try: user_db.update(condition, data['id'][0], table) return json.dumps({'code':0,'result':'update idc success'}) except: print traceback.print_exc() return json.dumps({'code':1,'result':'update idc failed'}) else: id = request.args.get('id') fields = ['id','name','isp','contact','mobile','address'] try: res = user_db.selectId(fields,id,table) idc = dict((k,res[i]) for i,k in enumerate(fields)) print idc return json.dumps({'code':0, 'result':idc}) except: print traceback.print_exc() return json.dumps({'code':1, 'result':'select idcinfo failed'})
def update(): if not session.get('name',None): return redirect('login.html') if request.method == "POST": data = dict(request.form) condition = [ "%s='%s'" % (k,v[0]) for k,v in data.items() ] try: user_db.update(condition, data['id'][0]) return redirect('/userlist') except: errmsg = "update user failed" print traceback.print_exc() return render_template("update.html",result = errmsg) else: id = request.args.get('id') fields = ['id', 'name', 'name_cn', 'email', 'mobile'] try: res = user_db.selectId(fields,id) user = dict((k,res[i]) for i,k in enumerate(fields)) return render_template('update.html', user = user) except: errmsg = "select userinfo failed" print traceback.print_exc() return render_template("update.html", result = errmsg)
def update(): table = 'users' if not session.get('name',None): return redirect('/login') if request.method == "POST": data = dict(request.form) print data condition = [ "%s='%s'" % (k,v[0]) for k,v in data.items() ] try: user_db.update(condition, data['id'][0], table) return json.dumps({'code':0,'result':'update user success'}) except: print traceback.print_exc() return json.dumps({'code':1,'result':'update user failed'}) else: id = request.args.get('id') fields = ['id', 'name', 'name_cn', 'email', 'mobile'] try: res = user_db.selectId(fields,id,table) user = dict((k,res[i]) for i,k in enumerate(fields)) return json.dumps({'code':0, 'result':user}) except: print traceback.print_exc() return json.dumps({'code':1, 'result':'select userinfo failed'})