Merge pull request #2862 from kvibber/rssdate
Add dates to RSS feeds and sort by most recent first
This commit is contained in:
commit
aec99ba173
1 changed files with 26 additions and 6 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue