本文整理匯總了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)
示例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)
示例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)