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


Python Category.get_forums方法代码示例

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


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

示例1: test_category_get_forums

# 需要导入模块: from flaskbb.forum.models import Category [as 别名]
# 或者: from flaskbb.forum.models.Category import get_forums [as 别名]
def test_category_get_forums(forum, user):
    category = forum.category

    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)
        assert current_user.is_authenticated
        cat, forums = Category.get_forums(category.id, current_user)

        # Check if it is a list because in a category there are normally more
        # than one forum in it (not in these tests)
        assert isinstance(forums, list) is True

        assert forums == [(forum, None)]
        assert cat == category

        # Test the same thing with a logged out user
        logout_user()
        assert not current_user.is_authenticated
        cat, forums = Category.get_forums(category.id, current_user)

        # Check if it is a list because in a category there are normally more
        # than one forum in it (not in these tests)
        assert isinstance(forums, list) is True

        assert forums == [(forum, None)]
        assert cat == category
开发者ID:0xsKu,项目名称:flaskbb,代码行数:29,代码来源:test_forum_models.py

示例2: get

# 需要导入模块: from flaskbb.forum.models import Category [as 别名]
# 或者: from flaskbb.forum.models.Category import get_forums [as 别名]
    def get(self, category_id, slug=None):
        category, forums = Category.get_forums(
            category_id=category_id, user=real(current_user)
        )

        return render_template(
            "forum/category.html", forums=forums, category=category
        )
开发者ID:justanr,项目名称:flaskbb,代码行数:10,代码来源:views.py


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