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
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
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
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', '-id').select_related() qs = perms.filter_topics(self.request.user, qs) return qs
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.annotate(votes=Sum('vote_set__vote')).order_by('-sticky', '-votes').select_related() if not (self.request.user.is_superuser or self.request.user in self.forum.moderators.all()): if self.request.user.is_authenticated(): qs = qs.filter(Q(user=self.request.user)|Q(on_moderation=False)) else: qs = qs.filter(on_moderation=False) return qs
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() if not (self.request.user.is_superuser or self.request.user in self.forum.moderators.all()): if self.request.user.is_authenticated(): qs = qs.filter( Q(user=self.request.user) | Q(on_moderation=False)) else: qs = qs.filter(on_moderation=False) return qs