• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python perms.filter_topics函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pybb.permissions.perms.filter_topics函数的典型用法代码示例。如果您正苦于以下问题:Python filter_topics函数的具体用法?Python filter_topics怎么用?Python filter_topics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_queryset

    def get_queryset(self):
        if not perms.may_view_forum(self.request.user, self.forum):
            raise PermissionDenied

        qs = self.forum.topics.order_by("-sticky", "-updated", "-id").select_related()
        qs = perms.filter_topics(self.request.user, qs)
        return qs
开发者ID:JTLX,项目名称:pybbm,代码行数:7,代码来源:views.py


示例2: dispatch

    def dispatch(self, request, *args, **kwargs):
        if request.user.is_authenticated():
            self.user = request.user
        else:
            if defaults.PYBB_ENABLE_ANONYMOUS_POST:
                self.user, new = User.objects.get_or_create(**{username_field: defaults.PYBB_ANONYMOUS_USERNAME})
            else:
                from django.contrib.auth.views import redirect_to_login
                return redirect_to_login(request.get_full_path())

        self.forum = None
        self.topic = None
        if 'forum_id' in kwargs:
            self.forum = get_object_or_404(perms.filter_forums(request.user, Forum.objects.all()), pk=kwargs['forum_id'])
            if not perms.may_create_topic(self.user, self.forum):
                raise PermissionDenied
        elif 'topic_id' in kwargs:
            self.topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=kwargs['topic_id'])
            if not perms.may_create_post(self.user, self.topic):
                raise PermissionDenied

            self.quote = ''
            if 'quote_id' in request.GET:
                try:
                    quote_id = int(request.GET.get('quote_id'))
                except TypeError:
                    raise Http404
                else:
                    post = get_object_or_404(Post, pk=quote_id)
                    self.quote = defaults.PYBB_QUOTE_ENGINES[defaults.PYBB_MARKUP](post.body, getattr(post.user, username_field))

                if self.quote and request.is_ajax():
                    return HttpResponse(self.quote)
        return super(AddPostView, self).dispatch(request, *args, **kwargs)
开发者ID:pbiogy,项目名称:pybbm,代码行数:34,代码来源:views.py


示例3: get_queryset

    def get_queryset(self):
        self.forum = get_object_or_404(Forum.objects.all(), pk=self.kwargs['pk'])
        if not perms.may_view_forum(self.request.user, self.forum):
            raise PermissionDenied

        qs = self.forum.topics.order_by('-sticky', '-updated').select_related()
        qs = perms.filter_topics(self.request.user, qs)
        return qs
开发者ID:pbiogy,项目名称:pybbm,代码行数:8,代码来源:views.py


示例4: add_subscription

def add_subscription(request, topic_id): # VERIFIED
    topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=topic_id)
    if not perms.may_access_topic(request, topic):
        raise PermissionDenied
    if not perms.may_subscribe_topic(request.user, topic):
        raise PermissionDenied
    topic.subscribers.add(request.user)
    return HttpResponseRedirect(topic.get_absolute_url())
开发者ID:harikvpy,项目名称:pybbm,代码行数:8,代码来源:views.py


示例5: add_subscription

def add_subscription(request, topic_id):
    topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=topic_id)
    if not perms.may_subscribe_topic(request.user, topic):
        raise PermissionDenied
    topic.subscribers.add(request.user)
    msg = _('Subscription added. You will receive email notifications for replies to this topic.')
    messages.success(request, msg, fail_silently=True)
    return HttpResponseRedirect(topic.get_absolute_url())
开发者ID:fizista,项目名称:pybbm,代码行数:8,代码来源:views.py


示例6: get_queryset

 def get_queryset(self):
     self.topic = get_object_or_404(perms.filter_topics(self.request.user, Topic.objects.select_related('forum')), pk=self.kwargs['pk'])
     self.topic.views += 1
     self.topic.save()
     qs = self.topic.posts.all().select_related('user')
     if not perms.may_moderate_topic(self.request.user, self.topic):
         qs = perms.filter_posts(self.request.user, qs)
     return qs
开发者ID:mjahn86,项目名称:ultimate-league-app,代码行数:8,代码来源:views.py


示例7: get_context_data

 def get_context_data(self, **kwargs):
     data = super(MovePostView, self).get_context_data()
     data['is_move'] = True
     # FIXME move to settings
     MOVE_POST_TIMEDELTA = 720
     since = datetime.today() - timedelta(days=MOVE_POST_TIMEDELTA)
     topic_qs = Topic.objects.filter(updated__gt=since)
     topic_qs = perms.filter_topics(self.request.user, topic_qs)
     data['move_to_topic_list'] = (topic_qs.select_related('forum')
                                   .order_by('forum', 'forum__name', 'name'))
     return data
开发者ID:5CORNERS,项目名称:www.le-francais.ru,代码行数:11,代码来源:views.py


示例8: get_context_data

    def get_context_data(self, **kwargs):
        context = super(GroupDetailView, self).get_context_data(**kwargs)
        group = self.get_object()

        # Images
        context['image_list'] = group.images.all()
        context['alias'] = 'gallery'

        # Misc
        context['user_is_member'] = self.request.user in group.members.all()
        context['user_is_invited'] = self.request.user in group.invited_users.all()
        context['user_is_moderator'] = self.request.user in group.moderators.all()

        # Forum
        topics = group.forum.topics.order_by('-sticky', '-updated', '-id').select_related()
        topics = perms.filter_topics(self.request.user, topics)
        context['topics'] = topics[:5]

        return context
开发者ID:astrobin,项目名称:astrobin,代码行数:19,代码来源:views.py


示例9: dispatch

    def dispatch(self, request, *args, **kwargs):
        if request.user.is_authenticated():
            self.user = request.user
        else:
            if defaults.PYBB_ENABLE_ANONYMOUS_POST:
                self.user, new = User.objects.get_or_create(**{username_field: defaults.PYBB_ANONYMOUS_USERNAME})
            else:
                from django.contrib.auth.views import redirect_to_login

                return redirect_to_login(request.get_full_path())

        self.forum = None
        self.topic = None
        if "forum_id" in kwargs:
            self.forum = get_object_or_404(
                perms.filter_forums(request.user, Forum.objects.all()), pk=kwargs["forum_id"]
            )
            if not perms.may_create_topic(self.user, self.forum):
                raise PermissionDenied
        elif "topic_id" in kwargs:
            self.topic = get_object_or_404(
                perms.filter_topics(request.user, Topic.objects.all()), pk=kwargs["topic_id"]
            )
            if not perms.may_create_post(self.user, self.topic):
                raise PermissionDenied

            self.quote = ""
            if "quote_id" in request.GET:
                try:
                    quote_id = int(request.GET.get("quote_id"))
                except TypeError:
                    raise Http404
                else:
                    post = get_object_or_404(Post, pk=quote_id)
                    if not perms.may_view_post(request.user, post):
                        raise PermissionDenied
                    profile = util.get_pybb_profile(post.user)
                    self.quote = util._get_markup_quoter(defaults.PYBB_MARKUP)(post.body, profile.get_display_name())

                if self.quote and request.is_ajax():
                    return HttpResponse(self.quote)
        return super(AddPostView, self).dispatch(request, *args, **kwargs)
开发者ID:JTLX,项目名称:pybbm,代码行数:42,代码来源:views.py


示例10: dispatch

    def dispatch(self, request, *args, **kwargs):
        if request.user.is_authenticated():
            self.user = request.user
        else:
            if defaults.PYBB_ENABLE_ANONYMOUS_POST:
                self.user, new = User.objects.get_or_create(username=defaults.PYBB_ANONYMOUS_USERNAME)
            else:
                from django.contrib.auth.views import redirect_to_login
                return redirect_to_login(request.get_full_path())

        self.forum = None
        self.topic = None
        if 'forum_id' in kwargs:
            self.forum = get_object_or_404(perms.filter_forums(request.user, Forum.objects.all()), pk=kwargs['forum_id'])
            if not perms.may_create_topic(self.user, self.forum):
                raise PermissionDenied
        elif 'topic_id' in kwargs:
            self.topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=kwargs['topic_id'])
            if not perms.may_create_post(self.user, self.topic):
                raise PermissionDenied
        return super(AddPostView, self).dispatch(request, *args, **kwargs)
开发者ID:mjahn86,项目名称:ultimate-league-app,代码行数:21,代码来源:views.py


示例11: items

 def items(self, user):
     return perms.filter_topics(user, Topic.objects.all()).select_related('forum').order_by('-created', '-id')[:15]
开发者ID:DylannCordel,项目名称:pybbm,代码行数:2,代码来源:feeds.py


示例12: items

 def items(self, user):
     return perms.filter_topics(user, Topic.objects.all()).order_by('-created')[:15]
开发者ID:acamposruiz,项目名称:quecoins,代码行数:2,代码来源:feeds.py


示例13: pybb_get_latest_topics

def pybb_get_latest_topics(context, cnt=5, user=None):
    qs = Topic.objects.all().order_by('-updated', '-created')
    if not user:
        user = context['user']
    qs = perms.filter_topics(user, qs)
    return qs[:cnt]
开发者ID:acamposruiz,项目名称:quecoins,代码行数:6,代码来源:pybb_tags.py


示例14: add_subscription

def add_subscription(request, topic_id):
    topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=topic_id)
    topic.subscribers.add(request.user)
    return HttpResponseRedirect(topic.get_absolute_url())
开发者ID:pbiogy,项目名称:pybbm,代码行数:4,代码来源:views.py


示例15: delete_subscription

def delete_subscription(request, topic_id):
    topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=topic_id)
    topic.subscribers.remove(request.user)
    msg = _('Subscription removed. You will not receive emails from this topic unless you subscribe or post again.')
    messages.success(request, msg, fail_silently=True)
    return HttpResponseRedirect(topic.get_absolute_url())
开发者ID:fizista,项目名称:pybbm,代码行数:6,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python perms.may_create_poll函数代码示例发布时间:2022-05-25
下一篇:
Python perms.filter_posts函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap