From e8b218274167346b942927ee146d096d48dfebf3 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 6 Mar 2024 11:46:03 -0600 Subject: range: added new paths for essays --- app/posts/views/craft_views.py | 2 +- app/posts/views/essay_views.py | 23 ++++++++++++++++++++++- app/posts/views/range_views.py | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'app/posts/views') diff --git a/app/posts/views/craft_views.py b/app/posts/views/craft_views.py index da5f2b1..409e393 100644 --- a/app/posts/views/craft_views.py +++ b/app/posts/views/craft_views.py @@ -17,7 +17,7 @@ class CraftListView(PaginatedListView): def get_queryset(self): queryset = super(CraftListView, self).get_queryset() - return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.HOWTO]).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') + return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.CRAFT]).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') def get_context_data(self, **kwargs): ''' diff --git a/app/posts/views/essay_views.py b/app/posts/views/essay_views.py index 02a1087..3c28834 100644 --- a/app/posts/views/essay_views.py +++ b/app/posts/views/essay_views.py @@ -7,7 +7,7 @@ from django.conf import settings from utils.views import PaginatedListView, LuxDetailView -from ..models import Post, PostType +from ..models import Post, PostType, PostTopic from taxonomy.models import Category @@ -29,6 +29,27 @@ class EssayListView(PaginatedListView): return context +class EssayCategoryList(PaginatedListView): + model = Post + template_name = "posts/essay_list.html" + + def get_queryset(self): + queryset = super(EssayCategoryList, self).get_queryset() + for t in PostTopic: + if t.label == self.kwargs['topic']: + topic = t + return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.ESSAY],post_topic=topic).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') + + def get_context_data(self, **kwargs): + ''' + override for custom breadcrumb path + ''' + # Call the base implementation first to get a context + context = super(EssayCategoryList, self).get_context_data(**kwargs) + context['breadcrumbs'] = ('Essay',) + return context + + class EssayDetailView(LuxDetailView): model = Post slug_field = "slug" diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py index f196e5e..dc09cee 100644 --- a/app/posts/views/range_views.py +++ b/app/posts/views/range_views.py @@ -24,7 +24,7 @@ class RangeListView(PaginatedListView): """ model = Post template_name = "posts/range_list.html" - queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM,PostType.HOWTO,PostType.REVIEW],status=1).order_by('-pub_date') + queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM,PostType.CRAFT,PostType.REVIEW],status=1).order_by('-pub_date') def get_context_data(self, **kwargs): context = super(RangeListView, self).get_context_data(**kwargs) -- cgit v1.2.3-70-g09d2