Skip to content
Browse files

passing archive-index to class-base view #140

  • Loading branch information...
1 parent 98c2033 commit dc56829beaac10f0fec80bd205925426bf134426 @Fantomas42 committed Apr 3, 2012
Showing with 12 additions and 8 deletions.
  1. +3 −6 zinnia/urls/archives.py
  2. +9 −2 zinnia/views/archives.py
View
9 zinnia/urls/archives.py
@@ -2,12 +2,9 @@
from django.conf.urls import url
from django.conf.urls import patterns
-from zinnia.settings import PAGINATION
from zinnia.settings import ALLOW_EMPTY
from zinnia.settings import ALLOW_FUTURE
-
-entry_conf_index = {'paginate_by': PAGINATION,
- 'template_name': 'zinnia/entry_archive.html'}
+from zinnia.views.archives import EntryIndex
entry_conf = {'date_field': 'creation_date',
'allow_empty': ALLOW_EMPTY,
@@ -23,10 +20,10 @@
urlpatterns = patterns(
'zinnia.views.archives',
url(r'^$',
- 'entry_index', entry_conf_index,
+ EntryIndex.as_view(),
name='zinnia_entry_archive_index'),
url(r'^page/(?P<page>\d+)/$',
- 'entry_index', entry_conf_index,
+ EntryIndex.as_view(),
name='zinnia_entry_archive_index_paginated'),
url(r'^(?P<year>\d{4})/$',
'entry_year', entry_conf_year,
View
11 zinnia/views/archives.py
@@ -11,17 +11,24 @@
"""
from datetime import date
-from django.views.generic.list_detail import object_list
+from django.views.generic.list import ListView
from django.views.generic.date_based import archive_year
from django.views.generic.date_based import archive_week
from django.views.generic.date_based import archive_month
from django.views.generic.date_based import archive_day
from zinnia.models import Entry
+from zinnia.settings import PAGINATION
from zinnia.views.decorators import update_queryset
+from zinnia.views.mixins import CallableQuerysetMixin
-entry_index = update_queryset(object_list, Entry.published.all)
+class EntryIndex(CallableQuerysetMixin, ListView):
+ """View for the archive index of the Weblog"""
+ paginate_by = PAGINATION
+ template_name = 'zinnia/entry_archive.html'
+ queryset = Entry.published.all
+
entry_year = update_queryset(archive_year, Entry.published.all)

0 comments on commit dc56829

Please sign in to comment.
Something went wrong with that request. Please try again.