本文整理汇总了Python中forms.FeedbackForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python FeedbackForm.validate_on_submit方法的具体用法?Python FeedbackForm.validate_on_submit怎么用?Python FeedbackForm.validate_on_submit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.FeedbackForm
的用法示例。
在下文中一共展示了FeedbackForm.validate_on_submit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feedback
# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import validate_on_submit [as 别名]
def feedback():
feedbackerrors = []
feedbackform = FeedbackForm()
user = None
given_feedback = []
if 'email' in session:
user = get_user(session['email'])
if user.role == 'admin':
# For admins, the feedback is shown
given_feedback = get_feedback()
if feedbackform.validate_on_submit():
feedback = Feedback(created = datetime.now(),
description=feedbackform.description.data,
user=user)
save_feedback(feedback)
flash(_(u"Feedback saved. Thank you!"))
return redirect(url_for('troikas'))
if feedbackform.errors:
for key, value in feedbackform.errors.items():
feedbackerrors.append(key + ': ' + value[0])
return render_template('feedback.html', feedbackform=feedbackform,
feedbackerrors=feedbackerrors,
given_feedback=given_feedback)
示例2: enter
# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import validate_on_submit [as 别名]
def enter():
#hacky hack
form = FeedbackForm(csrf_enabled = False)
if form.validate_on_submit():
print 'woot!'
ad = form_to_dict(form)
handle_form_data(ad)
return redirect('/')
return render_template('form.html',form = form)
示例3: send_feedback
# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import validate_on_submit [as 别名]
def send_feedback():
form = FeedbackForm()
if form.validate_on_submit():
newFeedback = Feedback(sender=g.user,text=form.text.data, timestamp=datetime.utcnow())
db.session.add(newFeedback)
db.session.commit()
flash('Your feedback has been submitted! Thank you!')
return redirect(url_for('index'))
return render_template('send_feedback.html',
form = form)
示例4: feedback
# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import validate_on_submit [as 别名]
def feedback():
if request.method == "GET":
return render_template("feedback.html", form=FeedbackForm())
form = FeedbackForm(request.form)
if form.validate_on_submit():
feedback = Feedback(form.name.data, form.email.data, form.message.data)
db.session.add(feedback)
db.session.commit()
flash("Thank you for your comment!")
return redirect(url_for("views.profiles"))
return render_template("feedback.html", form=form)