summaryrefslogtreecommitdiff
path: root/app/resume/views.py
blob: 3d0cd8d5cde35903ad3ee3615cd8ad00ce48597a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from django.views.generic.detail import DetailView
from django.views.generic.base import TemplateView
from django.shortcuts import get_object_or_404
from utils.views import PaginatedListView

from .models import PubItem, Publisher, Resume
from pages.models import Page


class PublisherListView(PaginatedListView):
    model = Publisher
    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/pubs.html"
    slug_field = "slug"


class PageView(DetailView):
    model = Page
    slug_field = "slug"

    def get_object(self, **kwargs):
        print("calling page view")
        return get_object_or_404(Page, path=self.kwargs['path'], slug=self.kwargs['slug'])

    def get_template_names(self):
        return ["details/%s.html" % self.object.slug, 'details/page.html']

    def get_context_data(self, **kwargs):
        # Call the base implementation first to get a context
        context = super(PageView, self).get_context_data(**kwargs)
        if self.kwargs['slug'] == 'resume':
            context['resume'] = Resume.objects.get(title='base')
        return context