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


Python Board.get_board_by_text_id方法代碼示例

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


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

示例1: get

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get_board_by_text_id [as 別名]
    def get(self, text_id):
        try:
            board = Board.get_board_by_text_id(text_id)
        except NoResultFound:
            return abort(404)

        #last_post = Post.query.order_by(Post.id.desc()).limit(1).subquery()
        #last_post_alias = aliased(Post, last_post)
        # threads = db.session.query(Thread, last_post_alias).filter_by(board_id=board.id).join(last_post_alias, Thread.id == last_post_alias.thread_id).order_by(Thread.id.desc()).all()
        threads = db.session.query(Thread).filter_by(board_id=board.id).order_by(Thread.id.desc()).all()

        #threads = db.session.query(Thread, Post)\
        #    .filter_by(board_id=board.id)\
        #    .order_by(Thread.id.desc())\
        #    .join(Post, Thread.id == Post.thread_id)\
        #    .all()

        #print(db.session.query(Thread, Post)
        #      .filter_by(board_id=board.id)
        #      .order_by(Thread.id.desc())
        #      .join(Post, Thread.id == Post.thread_id).statement)

        #for thread in threads:
        #    print(thread.__dict__)

        return render_template("forum_threads_view.jinja2", board=board, title=board.name, can_post=True,
                               threads=threads)
開發者ID:hansihe,項目名稱:FauxForum,代碼行數:29,代碼來源:board.py

示例2: get

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get_board_by_text_id [as 別名]
    def get(self, board_text_id):
        try:
            board = Board.get_board_by_text_id(board_text_id)
        except NoResultFound:
            return abort(404)

        form = ThreadPostForm()

        return render_template("forum_thread_post.jinja2", board=board, form=form)
開發者ID:hansihe,項目名稱:FauxForum,代碼行數:11,代碼來源:thread.py

示例3: post

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get_board_by_text_id [as 別名]
    def post(self, board_text_id):
        try:
            board = Board.get_board_by_text_id(board_text_id)
        except NoResultFound:
            return abort(404)

        form = ThreadPostForm()
        if form.validate():
            thread = Thread(form.title.data, board.id, current_user.id)
            db.session.add(thread)
            db.session.commit()

            post = Post(form.content.data, thread, current_user.id)
            post.op = True
            db.session.add(post)
            db.session.commit()

        return render_template("forum_thread_post.jinja2", board=board, form=form)
開發者ID:hansihe,項目名稱:FauxForum,代碼行數:20,代碼來源:thread.py


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