def idcupdate(): if request.method == 'GET': userid = request.args.get('id') data = {'id': userid} field = ['id', 'name', 'name_cn', 'address', 'adminer', 'phone'] ret = getone('idc', field, data)['msg'] else: data = {k: v[0] for k, v in dict(request.form).items()} field = ['name', 'name_cn', 'address', 'adminer', 'phone'] result = updateuser('idc', field, data) return json.dumps(result) return render_template('idc/idcupdate.html', idc=ret)
def serverupdate(): if request.method == 'GET': userid = request.args.get('id') data={'id':userid} field = ['id','hostname','lan_ip','wan_ip','cabinet_id','op','phone'] ret = getone('server',field,data)['msg'] else: data = {k:v[0] for k,v in dict(request.form).items()} field = ['hostname','lan_ip','wan_ip','cabinet_id','op','phone'] result = updateuser('server',field,data) return json.dumps(result) return render_template('server/serverupdate.html',server=ret)
def update_oneself(): if request.method == 'GET': userid = request.args.get('id') data = {'id': userid} field = ['id', 'name', 'name_cn', 'email', 'mobile'] result = getone('users', field, data) return json.dumps(result['msg']) else: data = {k: v[0] for k, v in dict(request.form).items()} field = ['name', 'name_cn', 'email', 'mobile'] result = updateuser('users', field, data) return json.dumps(result) return render_template('update.html')
def chpwdoneself(): if not session: return redirect('/login/') passwd = {k: v[0] for k, v in dict(request.form).items()} data = {'name': session['name']} field = ['id', 'name', 'password'] result = getone('users', field, data) if result['msg']['password'] == passwd['oldpasswd']: result['msg']['password'] = passwd['newpasswd'] field = ['password'] result = updateuser('users', field, data=result['msg']) else: result = {'code': 1, 'msg': u"旧密码不正确请重新输入!"} return json.dumps(result)
def cabinetupdate(): if request.method == 'GET': userid = request.args.get('id') data = {'id': userid} field = ['id', 'name', 'idc_id', 'u_num', 'power'] ret = getone('cabinet', field, data)['msg'] idc_field = ['id', 'name'] idcs = listall('idc', idc_field)['msg'] else: data = {k: v[0] for k, v in dict(request.form).items()} field = ['name', 'idc_id', 'u_num', 'power'] result = updateuser('cabinet', field, data) return json.dumps(result) return render_template('cabinet/cabinetupdate.html', cabinet=ret, idcs=idcs)