summaryrefslogtreecommitdiff
path: root/app/posts/views
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2024-02-25 16:43:51 -0600
committerluxagraf <sng@luxagraf.net>2024-02-25 16:43:51 -0600
commit164eee8075761c46add169fe5631f45f1ec8746d (patch)
tree59118b702104e356e301bb86e6a6edb060311931 /app/posts/views
parentdfdfae5272f36f0b21ac895a880237a5c0e61f04 (diff)
jrnl: re-arranged to make Range a repository for everything.
Diffstat (limited to 'app/posts/views')
-rw-r--r--app/posts/views/essay_views.py3
-rw-r--r--app/posts/views/film_views.py3
-rw-r--r--app/posts/views/guide_views.py48
-rw-r--r--app/posts/views/range_views.py18
-rw-r--r--app/posts/views/repair_views.py53
-rw-r--r--app/posts/views/review_views.py53
6 files changed, 127 insertions, 51 deletions
diff --git a/app/posts/views/essay_views.py b/app/posts/views/essay_views.py
index ca1697f..02a1087 100644
--- a/app/posts/views/essay_views.py
+++ b/app/posts/views/essay_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
@@ -43,6 +44,8 @@ class EssayDetailView(LuxDetailView):
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
+ context['breadcrumbs'] = ('Range',)
+ context['crumb_url'] = reverse('range:range-list')
return context
def get_template_names(self):
diff --git a/app/posts/views/film_views.py b/app/posts/views/film_views.py
index 3122240..48bdaa4 100644
--- a/app/posts/views/film_views.py
+++ b/app/posts/views/film_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
@@ -43,6 +44,8 @@ class FilmDetailView(LuxDetailView):
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
+ context['breadcrumbs'] = ('Range',)
+ context['crumb_url'] = reverse('range:range-list')
return context
def get_template_names(self):
diff --git a/app/posts/views/guide_views.py b/app/posts/views/guide_views.py
index 641da66..e19a7db 100644
--- a/app/posts/views/guide_views.py
+++ b/app/posts/views/guide_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 Guide, Post, PostType
from taxonomy.models import Category
@@ -15,44 +15,18 @@ class GuideListView(PaginatedListView):
"""
Return a list of Entries in reverse chronological order
"""
- model = Post
+ model = Guide
template_name = "posts/guide_base.html"
def get_queryset(self):
queryset = super(GuideListView, self).get_queryset()
- 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):
- """
- Return a list of Posts by topic in reverse chronological order
- """
- model = Post
- template_name = "posts/guide_by_topic.html"
-
- def get_queryset(self):
- queryset = super(GuideTopicListView, self).get_queryset()
- topic = Category.objects.get(slug=self.kwargs['topic'])
- return queryset.filter(status__exact=1).filter(topics__slug=topic.slug).order_by('-pub_date').prefetch_related('featured_image')
-
- def get_context_data(self, **kwargs):
- context = super(GuideTopicListView, self).get_context_data(**kwargs)
- 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
+ return queryset.filter(status__exact=1)
class GuideDetailView(LuxDetailView):
- model = Post
+ model = Guide
slug_field = "slug"
- def get_template_names(self):
- obj = self.get_object()
- return ["posts/%s_detail.html" % obj.get_post_type_display(), 'posts/post_detail.html']
def get_context_data(self, **kwargs):
context = super(GuideDetailView, self).get_context_data(**kwargs)
@@ -61,8 +35,14 @@ class GuideDetailView(LuxDetailView):
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
- topic = Category.objects.get(slug=self.kwargs['topic'])
- context['topic'] = topic
- context['breadcrumbs'] = ('Guides', topic.name )
- context['crumb_url'] = reverse('guides:guide-base')
+ context['breadcrumbs'] = ('Guides', self.object.title )
+ context['crumb_url'] = reverse('guides:guide-list')
return context
+
+
+class GuidePostDetailView(LuxDetailView):
+ model = Post
+ slug_field = "slug"
+ template_name = "posts/guide_post_detail.html"
+
+
diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py
index da3b61f..f196e5e 100644
--- a/app/posts/views/range_views.py
+++ b/app/posts/views/range_views.py
@@ -18,29 +18,13 @@ from locations.models import LuxCheckIn, Country, Region, Location
from sightings.models import Sighting
-class RangeDetailView(LuxDetailView):
- model = Post
- slug_field = "slug"
- template_name = "posts/range_detail.html"
-
- def get_context_data(self, **kwargs):
- context = super(RangeDetailView, 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
- context['mailing'] = NewsletterMailing.objects.get(post__id=self.object.id)
- return context
-
-
class RangeListView(PaginatedListView):
"""
Return a list of Newsletter posts in reverse chronological order
"""
model = Post
template_name = "posts/range_list.html"
- queryset = Post.objects.filter(post_type=PostType.RANGE,status=1).order_by('-pub_date')
+ queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM,PostType.HOWTO,PostType.REVIEW],status=1).order_by('-pub_date')
def get_context_data(self, **kwargs):
context = super(RangeListView, self).get_context_data(**kwargs)
diff --git a/app/posts/views/repair_views.py b/app/posts/views/repair_views.py
new file mode 100644
index 0000000..0a5eabf
--- /dev/null
+++ b/app/posts/views/repair_views.py
@@ -0,0 +1,53 @@
+from django.views.generic import ListView
+from django.views.generic.detail import DetailView
+from django.views.generic.dates import DateDetailView
+from django.urls import reverse
+from django.views.generic.dates import YearArchiveView, MonthArchiveView
+from django.contrib.syndication.views import Feed
+from django.apps import apps
+from django.shortcuts import get_object_or_404
+from django.conf import settings
+from django.db.models import Q
+
+from utils.views import PaginatedListView, LuxDetailView
+
+#from ..models import Entry, HomepageCurrator, Home
+from ..models import Post, PostType
+from locations.models import LuxCheckIn, Country, Region, Location
+from sightings.models import Sighting
+
+
+class RepairStoryDetailView(LuxDetailView):
+ model = Post
+ slug_field = "slug"
+ template_name = "posts/repair_detail.html"
+
+
+class RepairStoryListView(PaginatedListView):
+ """
+ Return a list of Newsletter posts in reverse chronological order
+ """
+ model = Post
+ template_name = "posts/repair_list.html"
+
+ def get_context_data(self, **kwargs):
+ context = super(FriendsListView, self).get_context_data(**kwargs)
+ context['breadcrumbs'] = ['repair',]
+ return context
+
+
+class FriendsRSSFeedView(Feed):
+ title = "Friends of a Long Year"
+ link = "/range/"
+ description = "Friends of a Long Year: A monthly newsletter"
+ description_template = 'feeds/blog_description.html'
+
+ def items(self):
+ return Post.objects.filter(status__exact=1).filter(post_type=PostType.FRIENDS).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
diff --git a/app/posts/views/review_views.py b/app/posts/views/review_views.py
new file mode 100644
index 0000000..353a5e9
--- /dev/null
+++ b/app/posts/views/review_views.py
@@ -0,0 +1,53 @@
+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
+
+from utils.views import PaginatedListView, LuxDetailView
+
+from ..models import Post, PostType
+from taxonomy.models import Category
+
+
+class ReviewListView(PaginatedListView):
+ model = Post
+ template_name = "posts/review_list.html"
+
+ def get_queryset(self):
+ queryset = super(ReviewListView, self).get_queryset()
+ return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.REVIEW]).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(ReviewListView, self).get_context_data(**kwargs)
+ context['breadcrumbs'] = ('Reviews',)
+ return context
+
+
+class ReviewDetailView(LuxDetailView):
+ model = Post
+ slug_field = "slug"
+
+ def get_context_data(self, **kwargs):
+ context = super(ReviewDetailView, 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
+ context['breadcrumbs'] = ('Range',)
+ context['crumb_url'] = reverse('range:range-list')
+ return context
+
+ def get_template_names(self):
+ obj = self.get_object()
+ return ["posts/review_detail.html"]
+
+
+class ReviewDetailViewTXT(ReviewDetailView):
+ template_name = "posts/entry_detail.txt"