diff options
author | luxagraf <sng@luxagraf.net> | 2023-12-19 12:13:02 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-12-19 12:13:02 -0500 |
commit | a9372a44b7249f5420cee82fd730627a5dc5f882 (patch) | |
tree | b5e1c5b1e483f470e347e935f68467d586bb9fa4 /app/posts/views/guide_views.py | |
parent | 6d6c2d29808dab7a755021c831b4aa95bf18c7a2 (diff) |
guides: built out publishing system for darktable guides
Diffstat (limited to 'app/posts/views/guide_views.py')
-rw-r--r-- | app/posts/views/guide_views.py | 61 |
1 files changed, 12 insertions, 49 deletions
diff --git a/app/posts/views/guide_views.py b/app/posts/views/guide_views.py index 346fcc7..a4ff873 100644 --- a/app/posts/views/guide_views.py +++ b/app/posts/views/guide_views.py @@ -1,6 +1,7 @@ from django.views.generic import ListView from django.views.generic.detail import DetailView from django.contrib.syndication.views import Feed +from django.urls import reverse from django.apps import apps from django.conf import settings @@ -19,7 +20,7 @@ class GuideListView(PaginatedListView): def get_queryset(self): queryset = super(GuideListView, self).get_queryset() - return queryset.filter(status__exact=1).filter(post_type__in=[PostType.REVIEW,PostType.FIELD_TEST]).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') + return queryset.filter(status__exact=1).filter(post_type__in=[PostType.REVIEW,PostType.GUIDE]).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') class GuideTopicListView(PaginatedListView): @@ -39,63 +40,25 @@ class GuideTopicListView(PaginatedListView): topic = Category.objects.get(slug=self.kwargs['topic']) context['topic'] = topic context['breadcrumbs'] = ('Guides', topic.name ) - + context['crumb_url'] = reverse('guides:guide-base') Category.objects.get(slug=self.kwargs['topic']) return context -class ReviewsListView(GuideListView): - template_name = "posts/post.html" - - def get_queryset(self): - queryset = super(ReviewsListView, self).get_queryset() - return queryset.filter(post_type__in=[0,1]).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') - - def get_context_data(self, **kwargs): - context = super(ReviewsListView, self).get_context_data(**kwargs) - context['archive_type'] = 'Field Tests' - return context - - -class PostDetailView(LuxDetailView): +class GuideDetailView(LuxDetailView): model = Post slug_field = "slug" - def get_queryset(self): - queryset = super(PostDetailView, self).get_queryset() - return queryset.select_related('location').prefetch_related('field_notes') - - def get_context_data(self, **kwargs): - context = super(PostDetailView, self).get_context_data(**kwargs) - related = [] - for obj in self.object.related.all(): - model = apps.get_model(obj.model_name.app_label, obj.model_name.model) - related.append(model.objects.get(slug=obj.slug, pub_date=obj.pub_date)) - context['related'] = related - return context - def get_template_names(self): obj = self.get_object() return ["posts/%s_detail.html" % obj.get_post_type_display(), 'posts/post_detail.html'] - -class PostDetailViewTXT(PostDetailView): - template_name = "posts/entry_detail.txt" - - -class PostsRSSFeedView(Feed): - title = "VanLifeReviews.com: " - link = "/" - description = "Latest reviews, stories and guides" - description_template = 'feeds/blog_description.html' - - def items(self): - return Post.objects.filter(status__exact=1).order_by('-pub_date')[:10] - - def item_pubdate(self, item): - """ - Takes an item, as returned by items(), and returns the item's - pubdate. - """ - return item.pub_date + def get_context_data(self, **kwargs): + context = super(GuideDetailView, self).get_context_data(**kwargs) + print(self.kwargs['topic']) + topic = Category.objects.get(slug=self.kwargs['topic']) + context['topic'] = topic + context['breadcrumbs'] = ('Guides', topic.name ) + context['crumb_url'] = reverse('guides:guide-base') + return context |