- def paginate(self, objects, page_number):
- try:
- return paginate(objects, self.entries_per_page, page_number)
- except EmptyPage:
- raise Http404
-
- def index_view(self, request, node=None, extra_context=None):
- paginated_page, entries = self.paginate(self.blog.entries.all(), request.GET.get('page', 1))
- context = {}
- context.update(extra_context or {})
- context.update({'blog': self.blog, 'entries': entries, 'paginated_page': paginated_page})
- return self.index_page.render_to_response(node, request, extra_context=context)
-
- def entry_view(self, request, slug, year=None, month=None, day=None, node=None, extra_context=None):
- entries = self.blog.entries.all()
- if year:
- entries = entries.filter(date__year=year)
- if month:
- entries = entries.filter(date__month=month)
- if day:
- entries = entries.filter(date__day=day)
- try:
- entry = entries.get(slug=slug)
- except:
- raise Http404
- context = {}
- context.update(extra_context or {})
- context.update({'blog': self.blog, 'entry': entry})
- return self.entry_page.render_to_response(node, request, extra_context=context)
+ def get_all_entries(self, request, node=None, extra_context=None):
+ return self.blog.entries.all(), extra_context