from django.views.generic.detail import DetailView from django.views.generic.base import TemplateView from utils.views import PaginatedListView from .models import PubItem, Publisher from pages.models import Page class PublisherListView(PaginatedListView): template_name = 'archives/resume-pubs.html' def get_queryset(self): return PubItem.objects.all() def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super(PublisherListView, self).get_context_data(**kwargs) context['pub_list'] = Publisher.objects.all() return context class ByPublisherListView(PaginatedListView): template_name = 'archives/resume-pubs-by-pub.html' def get_queryset(self): print(self.kwargs['publisher']) return PubItem.objects.filter(publisher__slug=self.kwargs['publisher']) def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super(ByPublisherListView, self).get_context_data(**kwargs) context['publisher'] = Publisher.objects.get(slug=self.kwargs['publisher']) return context class PubItemDetailView(DetailView): model = PubItem template_name = "details/resume.html" slug_field = "slug" class PageView(DetailView): model = Page slug_field = "slug" def get_queryset(self): try: return Page.objects.get(path__startswith=self.kwargs['path']) except: return Page.objects.get(path__startswith=self.kwargs['path'],slug=self.kwargs['slug']) def get_template_names(self): return ["details/%s.html" % self.object.slug, 'details/page.html']