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


Python Category.get_all方法代码示例

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


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

示例1: test_category_get_all

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

    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)
        assert current_user.is_authenticated
        categories = Category.get_all(current_user)

        # All categories are stored in a list
        assert isinstance(categories, list)
        # The forums for a category are also stored in a list
        assert isinstance(categories[0][1], list)

        assert categories == [(category, [(forum, None)])]

        # Test with logged out user
        logout_user()
        assert not current_user.is_authenticated
        categories = Category.get_all(current_user)

        # All categories are stored in a list
        assert isinstance(categories, list)
        # The forums for a category are also stored in a list
        assert isinstance(categories[0][1], list)

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

示例2: index

# 需要导入模块: from flaskbb.forum.models import Category [as 别名]
# 或者: from flaskbb.forum.models.Category import get_all [as 别名]
def index(payload=''):
    categories = Category.get_all(user=current_user)

    # Fetch a few stats about the forum
    user_count = User.query.count()
    topic_count = Topic.query.count()
    post_count = Post.query.count()
    newest_user = User.query.order_by(User.id.desc()).first()

    # Check if we use redis or not
    if not current_app.config["REDIS_ENABLED"]:
        online_users = User.query.filter(User.lastseen >= time_diff()).count()

        # Because we do not have server side sessions, we cannot check if there
        # are online guests
        online_guests = None
    else:
        online_users = len(get_online_users())
        online_guests = len(get_online_users(guest=True))

    return render_template("forum/index.html",
                           categories=categories,
                           user_count=user_count,
                           topic_count=topic_count,
                           post_count=post_count,
                           newest_user=newest_user,
                           online_users=online_users,
                           online_guests=online_guests,
                           # XSS added for educational purpose
                           payload=payload)
开发者ID:centime,项目名称:xss-paper,代码行数:32,代码来源:views.py


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