当前位置: 首页>>代码示例>>Python>>正文


Python FeedbackForm.validate_on_submit方法代码示例

本文整理汇总了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)
开发者ID:ttiurani,项目名称:troikalearning,代码行数:28,代码来源:views.py

示例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)
开发者ID:madhavsuresh,项目名称:premier,代码行数:11,代码来源:views.py

示例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)
开发者ID:JrtPec,项目名称:coopkot,代码行数:12,代码来源:views.py

示例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)
开发者ID:ramin32,项目名称:Hangspot,代码行数:15,代码来源:views.py


注:本文中的forms.FeedbackForm.validate_on_submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。