def UserAdd(): name = request.form.get('name') age = request.form.get('age','') passwd = request.form.get('passwd','') job = request.form.get('job','') sex = request.form.get('sex','') aihao = request.form.getlist('aihao') department = request.form.get('department') files = request.files.get('file') if files: print files.filename files.save("/tmp/%s"%files.filename) print sex,aihao,department,files if request.method == 'GET': return render_template('user/user_add.html') elif request.method == 'POST': _is_ok, error = user.vilidate_find(name,passwd,age,job) if _is_ok: flash(error) return render_template('user/user_add.html') else: if user.add_user(name,passwd,age,job): flash(u'添加: %s成功'%name) return redirect('/user/list/') else: return render_template('user/user_add.html', error=u'用户写入失败.')
def UserAdd(): name = request.form.get('name') age = request.form.get('age', '') passwd = request.form.get('passwd', '') job = request.form.get('job', '') if request.method == 'GET': return render_template('user_add.html') elif request.method == 'POST': _is_ok, error = user.vilidate_find(name, passwd, age, job) if _is_ok: flash(error) return render_template('user_add.html') else: if user.add_user(name, passwd, age, job): flash(u'添加: %s成功' % name) return redirect('/user/list/') else: return render_template('user_add.html', error=u'用户写入失败.')
def UserAdd(): name = request.form.get('name') age = request.form.get('age', '') passwd = request.form.get('passwd', '') job = request.form.get('job', '') file = request.files.get('file') if file: file.save("/tmp/%s" % file.filename) if request.method == 'GET': return render_template('user/user_add.html') elif request.method == 'POST': _is_ok, error = user.vilidate_find(name, passwd, age, job) if _is_ok: # flash(error) # return render_template('user/user_add.html') return json.dumps({"is_ok": _is_ok, "error": error}) else: if user.add_user(name, passwd, age, job): # flash(u'添加: %s成功'%name) # return redirect('/user/list/') return json.dumps({"is_ok": _is_ok, "error": error}) else: # return render_template('user/user_add.html', error=u'用户写入失败.') return json.dumps({"is_ok": _is_ok, "error": error})