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


Python Forum.get_topics方法代码示例

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


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

示例1: test_forum_get_topics

# 需要导入模块: from flaskbb.forum.models import Forum [as 别名]
# 或者: from flaskbb.forum.models.Forum import get_topics [as 别名]
def test_forum_get_topics(topic, user):
    forum = topic.forum
    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)

        topics = Forum.get_topics(forum_id=forum.id, user=current_user)

        assert topics.items == [(topic, None)]

        # Test with logged out user
        logout_user()

        topics = Forum.get_topics(forum_id=forum.id, user=current_user)

        assert topics.items == [(topic, None)]
开发者ID:0xsKu,项目名称:flaskbb,代码行数:18,代码来源:test_forum_models.py

示例2: get

# 需要导入模块: from flaskbb.forum.models import Forum [as 别名]
# 或者: from flaskbb.forum.models.Forum import get_topics [as 别名]
    def get(self, forum_id, slug=None):

        forum_instance, forumsread = Forum.get_forum(
            forum_id=forum_id, user=real(current_user)
        )

        if forum_instance.external:
            return redirect(forum_instance.external)

        # remove the current forum from the select field (move).
        available_forums = Forum.query.order_by(Forum.position).all()
        available_forums.remove(forum_instance)
        page = request.args.get("page", 1, type=int)
        topics = Forum.get_topics(
            forum_id=forum_instance.id,
            user=real(current_user),
            page=page,
            per_page=flaskbb_config["TOPICS_PER_PAGE"]
        )

        return render_template(
            "forum/edit_forum.html",
            forum=forum_instance,
            topics=topics,
            available_forums=available_forums,
            forumsread=forumsread,
        )
开发者ID:justanr,项目名称:flaskbb,代码行数:29,代码来源:views.py

示例3: view_forum

# 需要导入模块: from flaskbb.forum.models import Forum [as 别名]
# 或者: from flaskbb.forum.models.Forum import get_topics [as 别名]
def view_forum(forum_id, slug=None):
    page = request.args.get('page', 1, type=int)

    forum, forumsread = Forum.get_forum(forum_id=forum_id, user=current_user)
    topics = Forum.get_topics(forum_id=forum.id, user=current_user, page=page,
                              per_page=current_app.config["TOPICS_PER_PAGE"])

    return render_template("forum/forum.html", forum=forum, topics=topics,
                           forumsread=forumsread,)
开发者ID:xuemy,项目名称:flaskbb,代码行数:11,代码来源:views.py

示例4: view_forum

# 需要导入模块: from flaskbb.forum.models import Forum [as 别名]
# 或者: from flaskbb.forum.models.Forum import get_topics [as 别名]
def view_forum(forum_id, slug=None):
    page = request.args.get('page', 1, type=int)

    forum_instance, forumsread = Forum.get_forum(forum_id=forum_id,
                                                 user=current_user)

    if forum_instance.external:
        return redirect(forum_instance.external)

    topics = Forum.get_topics(
        forum_id=forum_instance.id, user=current_user, page=page,
        per_page=flaskbb_config["TOPICS_PER_PAGE"]
    )

    return render_template(
        "forum/forum.html", forum=forum_instance,
        topics=topics, forumsread=forumsread,
    )
开发者ID:delida,项目名称:flaskbb,代码行数:20,代码来源:views.py

示例5: manage_forum

# 需要导入模块: from flaskbb.forum.models import Forum [as 别名]
# 或者: from flaskbb.forum.models.Forum import get_topics [as 别名]
def manage_forum(forum_id, slug=None):
    page = request.args.get('page', 1, type=int)

    forum_instance, forumsread = Forum.get_forum(forum_id=forum_id,
                                                 user=current_user)

    # remove the current forum from the select field (move).
    available_forums = Forum.query.order_by(Forum.position).all()
    available_forums.remove(forum_instance)

    if not Permission(IsAtleastModeratorInForum(forum=forum_instance)):
        flash(_("You do not have the permissions to moderate this forum."),
              "danger")
        return redirect(forum_instance.url)

    if forum_instance.external:
        return redirect(forum_instance.external)

    topics = Forum.get_topics(
        forum_id=forum_instance.id, user=current_user, page=page,
        per_page=flaskbb_config["TOPICS_PER_PAGE"]
    )

    mod_forum_url = url_for("forum.manage_forum", forum_id=forum_instance.id,
                            slug=forum_instance.slug)

    # the code is kind of the same here but it somehow still looks cleaner than
    # doin some magic
    if request.method == "POST":
        ids = request.form.getlist("rowid")
        tmp_topics = Topic.query.filter(Topic.id.in_(ids)).all()

        # locking/unlocking
        if "lock" in request.form:
            changed = do_topic_action(topics=tmp_topics, user=current_user,
                                      action="locked", reverse=False)

            flash(_("%(count)s Topics locked.", count=changed), "success")
            return redirect(mod_forum_url)

        elif "unlock" in request.form:
            changed = do_topic_action(topics=tmp_topics, user=current_user,
                                      action="locked", reverse=True)
            flash(_("%(count)s Topics unlocked.", count=changed), "success")
            return redirect(mod_forum_url)

        # highlighting/trivializing
        elif "highlight" in request.form:
            changed = do_topic_action(topics=tmp_topics, user=current_user,
                                      action="important", reverse=False)
            flash(_("%(count)s Topics highlighted.", count=changed), "success")
            return redirect(mod_forum_url)

        elif "trivialize" in request.form:
            changed = do_topic_action(topics=tmp_topics, user=current_user,
                                      action="important", reverse=True)
            flash(_("%(count)s Topics trivialized.", count=changed), "success")
            return redirect(mod_forum_url)

        # deleting
        elif "delete" in request.form:
            changed = do_topic_action(topics=tmp_topics, user=current_user,
                                      action="delete", reverse=False)
            flash(_("%(count)s Topics deleted.", count=changed), "success")
            return redirect(mod_forum_url)

        # moving
        elif "move" in request.form:
            new_forum_id = request.form.get("forum")

            if not new_forum_id:
                flash(_("Please choose a new forum for the topics."), "info")
                return redirect(mod_forum_url)

            new_forum = Forum.query.filter_by(id=new_forum_id).first_or_404()
            # check the permission in the current forum and in the new forum

            if not Permission(
                And(
                    IsAtleastModeratorInForum(forum_id=new_forum_id),
                    IsAtleastModeratorInForum(forum=forum_instance)
                )
            ):
                flash(_("You do not have the permissions to move this topic."),
                      "danger")
                return redirect(mod_forum_url)

            new_forum.move_topics_to(tmp_topics)
            return redirect(mod_forum_url)

    return render_template(
        "forum/edit_forum.html", forum=forum_instance, topics=topics,
        available_forums=available_forums, forumsread=forumsread,
    )
开发者ID:hand-code,项目名称:flaskbb,代码行数:96,代码来源:views.py


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