diff options
author | lxf <sng@luxagraf.net> | 2022-05-14 16:38:07 -0400 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2022-05-14 16:38:07 -0400 |
commit | bb3973ffb714c932e9ec6dd6a751228dc71fe1d3 (patch) | |
tree | 6fa32f9392ad2ec32271349b86a4c1388fd6ba95 /app/pages/views.py |
initial commit
Diffstat (limited to 'app/pages/views.py')
-rw-r--r-- | app/pages/views.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/app/pages/views.py b/app/pages/views.py new file mode 100644 index 0000000..7ea2439 --- /dev/null +++ b/app/pages/views.py @@ -0,0 +1,40 @@ +from utils.views import LuxDetailView +from django.views.generic import DetailView + +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.html" % (obj.slug), 'pages/page_detail.html'] + + +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/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.HOMEPAGE).filter(status__exact=1).order_by('-pub_date')[1:9] + return context + + |