예제 #1
0
파일: views.py 프로젝트: fossabot/foxtail
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     today = datetime.today()
     context['post_list'] = queryset_filter(Post.objects).all()[:3]
     context['event_list'] = Event.objects.filter(
         Q(start__gte=today) | Q(end__gte=today))[:3]
     return context
예제 #2
0
    def get_context_data(self, form=None, **kwargs):
        context = super().get_context_data(**kwargs)
        context['sidebar_post_list'] = queryset_filter(Post.objects.all())[:3]
        context['sidebar_tag_list'] = Post.tags.most_common()[:8]

        if COMMENTS_ENABLED:
            context['comment_list'] = self.object.comments.all()
            context['comments_enabled'] = True
            if form:
                context['form'] = form
            else:
                if hasattr(self.request, 'csp_nonce'):
                    context['form'] = CommentForm(
                        csp_nonce=self.request.csp_nonce)
                else:
                    context['form'] = CommentForm()
        else:
            context['comments_enabled'] = False

        return context
예제 #3
0
 def items(self):
     return queryset_filter(Post.objects).order_by('-created')[:20]
예제 #4
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context['sidebar_post_list'] = queryset_filter(Post.objects).all()[:3]
     context['sidebar_tag_list'] = Post.tags.annotate(num_times=Count(
         'taggit_taggeditem_items')).order_by('-num_times')[:8]
     return context
예제 #5
0
 def items(self):
     return queryset_filter(Post.objects).all()