1
0
Fork 0

Merge pull request #2862 from kvibber/rssdate

Add dates to RSS feeds and sort by most recent first
This commit is contained in:
Mouse Reeve 2023-05-30 10:36:01 -07:00 committed by GitHub
commit aec99ba173
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,14 +36,22 @@ class RssFeed(Feed):
def items(self, obj): def items(self, obj):
"""the user's activity feed""" """the user's activity feed"""
return obj.status_set.select_subclasses().filter( return (
obj.status_set.select_subclasses()
.filter(
privacy__in=["public", "unlisted"], privacy__in=["public", "unlisted"],
)[:10] )
.order_by("-published_date")[:10]
)
def item_link(self, item): def item_link(self, item):
"""link to the status""" """link to the status"""
return item.local_path return item.local_path
def item_pubdate(self, item):
"""publication date of the item"""
return item.published_date
class RssReviewsOnlyFeed(Feed): class RssReviewsOnlyFeed(Feed):
"""serialize user's reviews in rss feed""" """serialize user's reviews in rss feed"""
@ -76,12 +84,16 @@ class RssReviewsOnlyFeed(Feed):
return Review.objects.filter( return Review.objects.filter(
user=obj, user=obj,
privacy__in=["public", "unlisted"], privacy__in=["public", "unlisted"],
)[:10] ).order_by("-published_date")[:10]
def item_link(self, item): def item_link(self, item):
"""link to the status""" """link to the status"""
return item.local_path return item.local_path
def item_pubdate(self, item):
"""publication date of the item"""
return item.published_date
class RssQuotesOnlyFeed(Feed): class RssQuotesOnlyFeed(Feed):
"""serialize user's quotes in rss feed""" """serialize user's quotes in rss feed"""
@ -114,12 +126,16 @@ class RssQuotesOnlyFeed(Feed):
return Quotation.objects.filter( return Quotation.objects.filter(
user=obj, user=obj,
privacy__in=["public", "unlisted"], privacy__in=["public", "unlisted"],
)[:10] ).order_by("-published_date")[:10]
def item_link(self, item): def item_link(self, item):
"""link to the status""" """link to the status"""
return item.local_path return item.local_path
def item_pubdate(self, item):
"""publication date of the item"""
return item.published_date
class RssCommentsOnlyFeed(Feed): class RssCommentsOnlyFeed(Feed):
"""serialize user's quotes in rss feed""" """serialize user's quotes in rss feed"""
@ -152,8 +168,12 @@ class RssCommentsOnlyFeed(Feed):
return Comment.objects.filter( return Comment.objects.filter(
user=obj, user=obj,
privacy__in=["public", "unlisted"], privacy__in=["public", "unlisted"],
)[:10] ).order_by("-published_date")[:10]
def item_link(self, item): def item_link(self, item):
"""link to the status""" """link to the status"""
return item.local_path return item.local_path
def item_pubdate(self, item):
"""publication date of the item"""
return item.published_date