summaryrefslogtreecommitdiff
path: root/app/posts
diff options
context:
space:
mode:
Diffstat (limited to 'app/posts')
-rw-r--r--app/posts/build.py29
-rw-r--r--app/posts/models.py12
-rw-r--r--app/posts/urls/friends_urls.py7
-rw-r--r--app/posts/urls/range_urls.py11
-rw-r--r--app/posts/views/friends_views.py15
-rw-r--r--app/posts/views/range_views.py15
6 files changed, 74 insertions, 15 deletions
diff --git a/app/posts/build.py b/app/posts/build.py
index 9a7e2c1..b49b925 100644
--- a/app/posts/build.py
+++ b/app/posts/build.py
@@ -18,6 +18,7 @@ class BuildSrc(BuildNew):
paginate_by=50
)
self.build_detail_view()
+ self.build_feed("src:feed")
class BuildGuide(BuildNew):
@@ -121,3 +122,31 @@ class BuildEssays(BuildNew):
paginate_by=50
)
self.build_detail_view()
+
+
+class BuildRange(BuildNew):
+
+ def get_model_queryset(self):
+ return self.model.objects.filter(post_type=PostType.RANGE).filter(status__exact=1).order_by('-pub_date')
+
+ def build(self):
+ self.build_list_view(
+ base_path=reverse("range:range-list"),
+ paginate_by=30
+ )
+ self.build_detail_view()
+ self.build_feed("range:feed")
+
+
+class BuildFriends(BuildNew):
+
+ def get_model_queryset(self):
+ return self.model.objects.filter(post_type=PostType.FRIENDS).filter(status__exact=1).order_by('-pub_date')
+
+ def build(self):
+ self.build_list_view(
+ base_path=reverse("friends:friends-list"),
+ paginate_by=30
+ )
+ self.build_detail_view()
+ self.build_feed("friends:feed")
diff --git a/app/posts/models.py b/app/posts/models.py
index 6adae3b..21dd6d5 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -32,8 +32,6 @@ from books.models import Book
from taxonomy.models import TaggedItems, Category
from utils.util import render_images, render_products, parse_video, markdown_to_html, extract_main_image
-from lttr.models import Newsletter
-
def get_upload_path(self, filename):
return "images/post-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
@@ -115,7 +113,7 @@ class Post(models.Model):
if self.post_type == PostType.JRNL:
return reverse('jrnl:detail', kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug})
if self.post_type == PostType.RANGE:
- return reverse('range:detail', kwargs={"issue": self.issue, "slug": self.slug})
+ return reverse('range:range-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug})
if self.post_type == PostType.FRIENDS:
return reverse('friends:friends-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug})
@@ -241,14 +239,6 @@ class PostModerator(CommentModerator):
return True
moderator.register(Post, PostModerator)
-#class PostMailing(models.Model):
-# newsletter = models.ForeignKey(Newsletter, null=True, on_delete=models.SET_NULL)
-# post = models.ForeignKey(Post, null=True, on_delete=models.SET_NULL)
-# body_email_html = models.TextField(blank=True)
-# issue = models.PositiveIntegerField()
-# date_sent = models.DateTimeField(blank=True, auto_now_add=True, editable=False)
-
-
@receiver(comment_was_posted, sender=Comment)
def cache_gravatar(sender, comment, **kwargs):
gravatar_exists = has_gravatar(comment.email)
diff --git a/app/posts/urls/friends_urls.py b/app/posts/urls/friends_urls.py
index 5998d08..b7f7608 100644
--- a/app/posts/urls/friends_urls.py
+++ b/app/posts/urls/friends_urls.py
@@ -7,6 +7,11 @@ app_name = "range"
urlpatterns = [
path(
+ r'feed.xml',
+ views.FriendsRSSFeedView(),
+ name="feed"
+ ),
+ path(
r'<int:issue>/<str:slug>',
views.FriendsDetailView.as_view(),
name="friends-detail"
@@ -15,6 +20,6 @@ urlpatterns = [
r'',
views.FriendsListView.as_view(),
{'page':1},
- name="friends-base"
+ name="friends-list"
),
]
diff --git a/app/posts/urls/range_urls.py b/app/posts/urls/range_urls.py
index 7b29569..16655d6 100644
--- a/app/posts/urls/range_urls.py
+++ b/app/posts/urls/range_urls.py
@@ -7,14 +7,19 @@ app_name = "range"
urlpatterns = [
path(
- r'<str:slug>',
+ r'feed.xml',
+ views.RangeRSSFeedView(),
+ name="feed"
+ ),
+ path(
+ r'<int:issue>/<str:slug>',
views.RangeDetailView.as_view(),
- name="detail"
+ name="range-detail"
),
path(
r'',
views.RangeListView.as_view(),
{'page':1},
- name="range-base"
+ name="range-list"
),
]
diff --git a/app/posts/views/friends_views.py b/app/posts/views/friends_views.py
index dd4dac2..3d6ea8d 100644
--- a/app/posts/views/friends_views.py
+++ b/app/posts/views/friends_views.py
@@ -37,3 +37,18 @@ class FriendsListView(PaginatedListView):
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/range_views.py b/app/posts/views/range_views.py
index 989134d..0a3a564 100644
--- a/app/posts/views/range_views.py
+++ b/app/posts/views/range_views.py
@@ -37,3 +37,18 @@ class RangeListView(PaginatedListView):
return context
+class RangeRSSFeedView(Feed):
+ title = "Range: A weekly photo, developed"
+ link = "/range/"
+ description = "Range: A weekly photo, developed"
+ description_template = 'feeds/blog_description.html'
+
+ def items(self):
+ return Post.objects.filter(status__exact=1).filter(post_type=PostType.RANGE).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