Exemple #1
0
    def get_context_data(self, **kwargs):
        section = kwargs['section']
        obj_id = kwargs['obj_id']

        # Article
        if obj_id:
            self.template_name = "blog_item.html"
            context = views.get_default_context(shortcuts.get_object_or_404(models.Article, pk=obj_id))
            context['last_articles'] = models.Article.objs.all().exclude(id=obj_id)\
                .select_related().prefetch_related('attachments')[:3]
            return context

        # Section
        self.template_name = "blog_list.html"
        context = views.get_default_context(section)
        context['articles'] = views.get_paginator(section.get_articles())

        return context
Exemple #2
0
 def get_context_data(self, **kwargs):
     section = kwargs['section']
     context = views.get_default_context(section)
     context['products'] = views.get_paginator(models.Product.get_by_category_name(section.name))
     return context
Exemple #3
0
 def product_list(self, context, catalog, **kwargs):
     self.template_name = "products.html"
     context['products'] = views.get_paginator(catalog.get_products())
     return context