當前位置: 首頁>>代碼示例>>Python>>正文


Python ReplyForm.save方法代碼示例

本文整理匯總了Python中flaskbb.forum.forms.ReplyForm.save方法的典型用法代碼示例。如果您正苦於以下問題:Python ReplyForm.save方法的具體用法?Python ReplyForm.save怎麽用?Python ReplyForm.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flaskbb.forum.forms.ReplyForm的用法示例。


在下文中一共展示了ReplyForm.save方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: reply_post

# 需要導入模塊: from flaskbb.forum.forms import ReplyForm [as 別名]
# 或者: from flaskbb.forum.forms.ReplyForm import save [as 別名]
def reply_post(topic_id, post_id):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()
    post = Post.query.filter_by(id=post_id).first_or_404()

    if post.topic.forum.locked:
        flash("This forum is locked; you cannot submit new topics or posts.",
              "danger")
        return redirect(post.topic.forum.url)

    if post.topic.locked:
        flash("The topic is locked.", "danger")
        return redirect(post.topic.forum.url)

    if not can_post_reply(user=current_user, forum=topic.forum):
        flash("You do not have the permissions to post in this topic", "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        if request.form['button'] == 'preview':
            return render_template("forum/new_post.html", topic=topic, form=form, preview=form.content.data)
        else:
            form.save(current_user, topic)
            return redirect(post.topic.url)
    else:
        form.content.data = '[quote]{}[/quote]'.format(post.content)

    return render_template("forum/new_post.html", topic=post.topic, form=form)
開發者ID:FooBarQuaxx,項目名稱:flaskbb,代碼行數:30,代碼來源:views.py

示例2: reply_post

# 需要導入模塊: from flaskbb.forum.forms import ReplyForm [as 別名]
# 或者: from flaskbb.forum.forms.ReplyForm import save [as 別名]
def reply_post(topic_id, post_id):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()
    post = Post.query.filter_by(id=post_id).first_or_404()

    if not can_post_reply(user=current_user, topic=topic):
        flash(_("You do not have the permissions to post in this topic."),
              "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        if "preview" in request.form:
            return render_template(
                "forum/new_post.html", topic=topic,
                form=form, preview=form.content.data
            )
        else:
            form.save(current_user, topic)
            return redirect(post.topic.url)
    else:
        form.content.data = format_quote(post)

    return render_template("forum/new_post.html", topic=post.topic, form=form)
開發者ID:delida,項目名稱:flaskbb,代碼行數:25,代碼來源:views.py

示例3: new_post

# 需要導入模塊: from flaskbb.forum.forms import ReplyForm [as 別名]
# 或者: from flaskbb.forum.forms.ReplyForm import save [as 別名]
def new_post(topic_id, slug=None):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()

    if not can_post_reply(user=current_user, topic=topic):
        flash("You do not have the permissions to post here", "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        if request.form['button'] == 'preview':
            return render_template("forum/new_post.html", topic=topic,
                                   form=form, preview=form.content.data)
        else:
            post = form.save(current_user, topic)
            return view_post(post.id)

    return render_template("forum/new_post.html", topic=topic, form=form)
開發者ID:centime,項目名稱:xss-paper,代碼行數:19,代碼來源:views.py

示例4: new_post

# 需要導入模塊: from flaskbb.forum.forms import ReplyForm [as 別名]
# 或者: from flaskbb.forum.forms.ReplyForm import save [as 別名]
def new_post(topic_id):
    topic = Topic.query.filter_by(id=topic_id).first()

    if topic.locked:
        flash("The topic is locked.", "error")
        return redirect(url_for("forum.view_forum", forum_id=topic.forum_id))

    if not perm_post_reply(user=current_user, forum=topic.forum):
        flash("You do not have the permissions to delete the topic", "error")
        return redirect(url_for("forum.view_forum", forum_id=topic.forum_id))

    form = ReplyForm()
    if form.validate_on_submit():
        post = form.save(current_user, topic)
        return view_post(post.id)

    return render_template("forum/new_post.html", topic=topic, form=form)
開發者ID:FrontSide,項目名稱:flaskbb,代碼行數:19,代碼來源:views.py

示例5: new_post

# 需要導入模塊: from flaskbb.forum.forms import ReplyForm [as 別名]
# 或者: from flaskbb.forum.forms.ReplyForm import save [as 別名]
def new_post(topic_id, slug=None):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()

    if not Permission(CanPostReply):
        flash(_("You do not have the permissions to post in this topic."),
              "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        if "preview" in request.form:
            return render_template(
                "forum/new_post.html", topic=topic,
                form=form, preview=form.content.data
            )
        else:
            post = form.save(current_user, topic)
            return view_post(post.id)

    return render_template("forum/new_post.html", topic=topic, form=form)
開發者ID:hand-code,項目名稱:flaskbb,代碼行數:22,代碼來源:views.py

示例6: new_post

# 需要導入模塊: from flaskbb.forum.forms import ReplyForm [as 別名]
# 或者: from flaskbb.forum.forms.ReplyForm import save [as 別名]
def new_post(topic_id, slug=None):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()

    if topic.forum.locked:
        flash("This forum is locked; you cannot submit new topics or posts.",
              "danger")
        return redirect(topic.forum.url)

    if topic.locked:
        flash("The topic is locked.", "danger")
        return redirect(topic.forum.url)

    if not can_post_reply(user=current_user, forum=topic.forum):
        flash("You do not have the permissions to delete the topic", "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        post = form.save(current_user, topic)
        return view_post(post.id)

    return render_template("forum/new_post.html", topic=topic, form=form)
開發者ID:xuemy,項目名稱:flaskbb,代碼行數:24,代碼來源:views.py


注:本文中的flaskbb.forum.forms.ReplyForm.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。