本文整理匯總了Python中flaskbb.forum.models.ForumsRead.user方法的典型用法代碼示例。如果您正苦於以下問題:Python ForumsRead.user方法的具體用法?Python ForumsRead.user怎麽用?Python ForumsRead.user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flaskbb.forum.models.ForumsRead
的用法示例。
在下文中一共展示了ForumsRead.user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from flaskbb.forum.models import ForumsRead [as 別名]
# 或者: from flaskbb.forum.models.ForumsRead import user [as 別名]
def post(self, forum_id=None, slug=None):
# Mark a single forum as read
if forum_id is not None:
forum_instance = Forum.query.filter_by(id=forum_id).first_or_404()
forumsread = ForumsRead.query.filter_by(
user_id=real(current_user).id, forum_id=forum_instance.id
).first()
TopicsRead.query.filter_by(
user_id=real(current_user).id, forum_id=forum_instance.id
).delete()
if not forumsread:
forumsread = ForumsRead()
forumsread.user = real(current_user)
forumsread.forum = forum_instance
forumsread.last_read = time_utcnow()
forumsread.cleared = time_utcnow()
db.session.add(forumsread)
db.session.commit()
flash(
_(
"Forum %(forum)s marked as read.",
forum=forum_instance.title
), "success"
)
return redirect(forum_instance.url)
# Mark all forums as read
ForumsRead.query.filter_by(user_id=real(current_user).id).delete()
TopicsRead.query.filter_by(user_id=real(current_user).id).delete()
forums = Forum.query.all()
forumsread_list = []
for forum_instance in forums:
forumsread = ForumsRead()
forumsread.user = real(current_user)
forumsread.forum = forum_instance
forumsread.last_read = time_utcnow()
forumsread.cleared = time_utcnow()
forumsread_list.append(forumsread)
db.session.add_all(forumsread_list)
db.session.commit()
flash(_("All forums marked as read."), "success")
return redirect(url_for("forum.index"))