summaryrefslogtreecommitdiff
path: root/app/pages/views.py
blob: d4c488087f9debb4b6fa48e0b4e85ff60db0ad31 (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
from utils.views import LuxDetailView
from django.views.generic import DetailView

from locations.models import LuxCheckIn
from posts.models import Post, PostType
from .models import Page, HomePage


class PageDetailView(LuxDetailView):
    model = Page

    def get_template_names(self):
        obj = self.get_object()
        return ["pages/%s/%s.html" % (obj.site.name, obj.slug), 'pages/%s/page_detail.html'% obj.site.name]


class PageDetailTXTView(LuxDetailView):
    model = Page
    slug_field = "slug"
    
    def get_template_names(self):
        obj = self.get_object()
        return 'pages/%s/page_detail.txt'% obj.site.name


class HomePageList(DetailView):
    """
    Return a main entry and list of Entries in reverse chronological order
    """
    model = HomePage

    def get_template_names(self):
        return ["pages/%s.html" % self.template_name, 'pages/luxagraf/homepage.html']

    def get_context_data(self, **kwargs):
        # Call the base implementation first to get a context
        context = super(HomePageList, self).get_context_data(**kwargs)
        context['object_list'] = Post.objects.filter(post_type=PostType.JRNL).filter(status__exact=1).order_by('-pub_date').exclude().select_related('location').select_related('featured_image')[1:9]
        context['location'] = LuxCheckIn.objects.latest()
        return context