diff options
author | luxagraf <sng@luxagraf.net> | 2015-11-08 19:54:58 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-11-08 19:54:58 -0500 |
commit | 76c0bf31bf4a21fcf18df8579dbb6f660c4d7437 (patch) | |
tree | 1088521913633ee867c62614b70ca0955302592e /app/jrnl/views.py | |
parent | a1122250e52d8773fb672ac60a458e4b7d6570fb (diff) |
Ported Bird app to CBV and modern URL structure. Also added base class
to utils module to handle my pagination scheme so I can reuse that bit
of code
Diffstat (limited to 'app/jrnl/views.py')
-rw-r--r-- | app/jrnl/views.py | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/app/jrnl/views.py b/app/jrnl/views.py index 893c7ea..e7f704b 100644 --- a/app/jrnl/views.py +++ b/app/jrnl/views.py @@ -2,40 +2,29 @@ from django.views.generic import ListView from django.views.generic.detail import DetailView from django.views.generic.dates import YearArchiveView, MonthArchiveView from django.contrib.syndication.views import Feed - from django.conf import settings +from utils.views import PaginatedListView + from .models import Entry, HomepageCurrator from locations.models import Country, Region -class EntryList(ListView): +class EntryList(PaginatedListView): """ Return a list of Entries in reverse chronological order """ - context_object_name = 'object_list' queryset = Entry.objects.filter(status__exact=1).order_by('-pub_date').select_related() template_name = "archives/writing.html" - def dispatch(self, request, *args, **kwargs): - request.page_url = '/jrnl/%d/' - request.page = int(self.kwargs['page']) - return super(EntryList, self).dispatch(request, *args, **kwargs) - -class EntryCountryList(ListView): +class EntryCountryList(PaginatedListView): """ Return a list of Entries by Country in reverse chronological order """ - context_object_name = 'object_list' template_name = "archives/writing.html" - def dispatch(self, request, *args, **kwargs): - request.page_url = '/jrnl/' + self.kwargs['slug'] + '/%d/' - request.page = int(self.kwargs['page']) - return super(EntryCountryList, self).dispatch(request, *args, **kwargs) - def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super(EntryCountryList, self).get_context_data(**kwargs) @@ -47,7 +36,7 @@ class EntryCountryList(ListView): def get_queryset(self): try: - region= Country.objects.get(slug__exact=self.kwargs['slug']) + region = Country.objects.get(slug__exact=self.kwargs['slug']) qs = Entry.objects.filter( status__exact=1, location__state__country=region @@ -117,4 +106,3 @@ class JrnlRSSFeedView(Feed): def items(self): return Entry.objects.filter(status__exact=1).order_by('-pub_date')[:10] - |