Ejemplo n.º 1
0
 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
Ejemplo n.º 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
Ejemplo n.º 3
0
 def items(self):
     return queryset_filter(Post.objects).order_by('-created')[:20]
Ejemplo n.º 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
Ejemplo n.º 5
0
 def items(self):
     return queryset_filter(Post.objects).all()