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


Python ReplyForm.populate_obj方法代码示例

本文整理汇总了Python中flaskbb.forum.forms.ReplyForm.populate_obj方法的典型用法代码示例。如果您正苦于以下问题:Python ReplyForm.populate_obj方法的具体用法?Python ReplyForm.populate_obj怎么用?Python ReplyForm.populate_obj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flaskbb.forum.forms.ReplyForm的用法示例。


在下文中一共展示了ReplyForm.populate_obj方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_post

# 需要导入模块: from flaskbb.forum.forms import ReplyForm [as 别名]
# 或者: from flaskbb.forum.forms.ReplyForm import populate_obj [as 别名]
def edit_post(post_id):
    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_edit_post(user=current_user, forum=post.topic.forum,
                         post_user_id=post.user_id):
        flash("You do not have the permissions to edit this post", "danger")
        return redirect(post.topic.url)

    form = ReplyForm()
    if form.validate_on_submit():
        if request.form['button'] == 'preview':
            return render_template("forum/new_post.html", topic=post.topic, form=form, preview=form.content.data)
        else:
            form.populate_obj(post)
            post.date_modified = datetime.datetime.utcnow()
            post.modified_by = current_user.username
            post.save()
            return redirect(post.topic.url)
    else:
        form.content.data = post.content

    return render_template("forum/new_post.html", topic=post.topic, form=form)
开发者ID:FooBarQuaxx,项目名称:flaskbb,代码行数:33,代码来源:views.py

示例2: edit_post

# 需要导入模块: from flaskbb.forum.forms import ReplyForm [as 别名]
# 或者: from flaskbb.forum.forms.ReplyForm import populate_obj [as 别名]
def edit_post(post_id):
    post = Post.query.filter_by(id=post_id).first_or_404()

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

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

    return render_template("forum/new_post.html", topic=post.topic, form=form)
开发者ID:hand-code,项目名称:flaskbb,代码行数:27,代码来源:views.py

示例3: edit_post

# 需要导入模块: from flaskbb.forum.forms import ReplyForm [as 别名]
# 或者: from flaskbb.forum.forms.ReplyForm import populate_obj [as 别名]
def edit_post(post_id):
    post = Post.query.filter_by(id=post_id).first()

    if post.topic.forum.locked:
        flash("This forum is locked; you cannot submit new topics or posts.", "error")
        return redirect(url_for('forum.view_forum', forum_id=post.topic.forum.id))

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

    if not perm_edit_post(user=current_user, forum=post.topic.forum,
                          post_user_id=post.user_id):
        flash("You do not have the permissions to edit this post", "error")
        return redirect(url_for('forum.view_topic', topic_id=post.topic_id))

    form = ReplyForm()
    if form.validate_on_submit():
        form.populate_obj(post)
        post.date_modified = datetime.datetime.utcnow()
        post.save()
        return redirect(url_for('forum.view_topic', topic_id=post.topic.id))
    else:
        form.content.data = post.content

    return render_template("forum/new_post.html", topic=post.topic, form=form)
开发者ID:RJacksonm1,项目名称:flaskbb,代码行数:28,代码来源:views.py


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