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


Python perms.filter_posts函数代码示例

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


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

示例1: get_queryset

    def get_queryset(self):
        if not perms.may_view_topic(self.request.user, self.topic):
            raise PermissionDenied
        if self.request.user.is_authenticated() or not defaults.PYBB_ANONYMOUS_VIEWS_CACHE_BUFFER:
            Topic.objects.filter(id=self.topic.id).update(views=F('views') + 1)
        else:
            cache_key = util.build_cache_key('anonymous_topic_views', topic_id=self.topic.id)
            cache.add(cache_key, 0)
            if cache.incr(cache_key) % defaults.PYBB_ANONYMOUS_VIEWS_CACHE_BUFFER == 0:
                Topic.objects.filter(id=self.topic.id).update(views=F('views') +
                                                                    defaults.PYBB_ANONYMOUS_VIEWS_CACHE_BUFFER)
                cache.set(cache_key, 0)
        qs = self.topic.posts.all().select_related('user')
        if defaults.PYBB_PROFILE_RELATED_NAME:
            if defaults.PYBB_POST_SORT_REVERSE:
                qs = qs.select_related('user__%s' % defaults.PYBB_PROFILE_RELATED_NAME).order_by('-created')
            else:
                qs = qs.select_related('user__%s' % defaults.PYBB_PROFILE_RELATED_NAME)

        if not perms.may_moderate_topic(self.request.user, self.topic):
            if defaults.PYBB_POST_SORT_REVERSE:
                qs = perms.filter_posts(self.request.user, qs).order_by('-created')
            else:
                qs = perms.filter_posts(self.request.user, qs)
        return qs
开发者ID:magatz,项目名称:pybbm,代码行数:25,代码来源:views.py

示例2: move_post_processing

def move_post_processing(request):
    if not request.method == 'POST':
        raise PermissionDenied

    field_list = ('move_from_topic', 'move_to_topic', 'move_post_list')
    if not all(field in request.POST for field in field_list):
        # FIXME print "select at least one post"
        return redirect(request.META['HTTP_REFERER'])

    move_from_topic = request.POST.get('move_from_topic')
    move_to_topic = request.POST.get('move_to_topic')
    move_post_list = list(set(request.POST.getlist('move_post_list')))

    old_topic = Topic.objects.get(pk=move_from_topic)
    new_topic = Topic.objects.get(pk=move_to_topic)

    if (not perms.may_moderate_topic(request.user, old_topic) or
            not perms.may_moderate_topic(request.user, new_topic)):
        raise PermissionDenied

    # filter by topic for prevent access violations
    post_qs = Post.objects.filter(topic=move_from_topic, pk__in=move_post_list)
    post_qs = perms.filter_posts(request.user, post_qs)
    post_qs.update(topic=move_to_topic)

    old_topic.update_counters()
    new_topic.update_counters()

    first_moved_post = Post.objects.get(pk=min(move_post_list))

    # FIXME print "success"
    return redirect(first_moved_post.get_absolute_url())
开发者ID:5CORNERS,项目名称:www.le-francais.ru,代码行数:32,代码来源:views.py

示例3: 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

示例4: get_queryset

    def get_queryset(self):
        if not perms.may_view_topic(self.request.user, self.topic):
            raise PermissionDenied

        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:hwangtamu,项目名称:pybbm,代码行数:10,代码来源:views.py

示例5: get_queryset

    def get_queryset(self):
        if not perms.may_view_topic(self.request.user, self.topic):
            raise PermissionDenied

        self.topic.views += 1
        self.topic.save()
        qs = self.topic.posts.all().select_related('user')
        if defaults.PYBB_PROFILE_RELATED_NAME:
            qs = qs.select_related('user__%s' % defaults.PYBB_PROFILE_RELATED_NAME)
        if not perms.may_moderate_topic(self.request.user, self.topic):
            qs = perms.filter_posts(self.request.user, qs)
        return qs
开发者ID:atas3,项目名称:pybbm,代码行数:12,代码来源:views.py

示例6: get_queryset

 def get_queryset(self):
     qs = super(UserPosts, self).get_queryset()
     qs = qs.filter(user=self.user)
     qs = perms.filter_posts(self.request.user, qs).select_related('topic')
     qs = qs.order_by('-created', '-updated')
     return qs
开发者ID:pbiogy,项目名称:pybbm,代码行数:6,代码来源:views.py

示例7: get_queryset

 def get_queryset(self):
     qs = super(UserPosts, self).get_queryset()
     qs = qs.filter(user=self.user)
     qs = perms.filter_posts(self.request.user, qs).select_related("topic")
     qs = qs.order_by("-created", "-updated", "-id")
     return qs
开发者ID:JTLX,项目名称:pybbm,代码行数:6,代码来源:views.py

示例8: pybb_get_latest_posts

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

示例9: get_redirect_url

 def get_redirect_url(self, **kwargs):
     post = get_object_or_404(perms.filter_posts(self.request.user, Post.objects.all()), pk=self.kwargs['pk'])
     count = post.topic.posts.filter(created__lt=post.created).count() + 1
     page = math.ceil(count / float(defaults.PYBB_TOPIC_PAGE_SIZE))
     return '%s?page=%d#post-%d' % (reverse('pybb:topic', args=[post.topic.id]), page, post.id)
开发者ID:mjahn86,项目名称:ultimate-league-app,代码行数:5,代码来源:views.py

示例10: items

 def items(self, user):
     ids = [p.id for p in perms.filter_posts(user, Post.objects.only('id')).order_by('-created', '-id')[:15]]
     return Post.objects.filter(id__in=ids).select_related('topic', 'topic__forum', 'user')
开发者ID:DylannCordel,项目名称:pybbm,代码行数:3,代码来源:feeds.py


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