def post(self): form = UseraddForm() if form.validate() == False: return render_template('user/useradd.html', form=form) else: newuser = User(form.nickname.data, form.username.data,form.identity.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() app.logger.info('Manager:%s add user :%s.',g.user,newuser) return redirect(url_for('user'))
def signup(): roles={1:"stu",2:"admin",3:"teacher"} if request.method == 'GET': return render_template('admin/useradd.html') form = UseraddForm(request.form) if form.validate(): uid,type=form.save() flash(u"用户添加成功!") if type==1 or type==3: return redirect("/admin/user-profile?id="+uid) return redirect("/admin/useradd") for fieldName, errorMessages in form.errors.iteritems(): for err in errorMessages: flash(err) return render_template('admin/useradd.html')