Add tags to feed
This commit is contained in:
parent
a8cd2742ab
commit
34dcf63a93
2 changed files with 6 additions and 2 deletions
|
@ -80,7 +80,7 @@ class BlogPostListPageTestCase(TestCase):
|
||||||
self.client.get(self.page.url)
|
self.client.get(self.page.url)
|
||||||
|
|
||||||
def test_feed_accessible(self) -> None:
|
def test_feed_accessible(self) -> None:
|
||||||
with self.assertNumQueries(12):
|
with self.assertNumQueries(14):
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
self.page.url + self.page.reverse_subpage("feed")
|
self.page.url + self.page.reverse_subpage("feed")
|
||||||
)
|
)
|
||||||
|
|
|
@ -114,7 +114,7 @@ class AllPagesFeed(Feed):
|
||||||
return item.get_full_url(request=self.request) + "?utm_medium=rss"
|
return item.get_full_url(request=self.request) + "?utm_medium=rss"
|
||||||
|
|
||||||
def item_pubdate(self, item: BasePage) -> datetime:
|
def item_pubdate(self, item: BasePage) -> datetime:
|
||||||
if item_date := item.date:
|
if item_date := getattr(item, "date", None):
|
||||||
return datetime.combine(item_date, time())
|
return datetime.combine(item_date, time())
|
||||||
return item.first_published_at
|
return item.first_published_at
|
||||||
|
|
||||||
|
@ -124,6 +124,10 @@ class AllPagesFeed(Feed):
|
||||||
def item_description(self, item: BasePage) -> str:
|
def item_description(self, item: BasePage) -> str:
|
||||||
return getattr(item, "summary", None) or item.title
|
return getattr(item, "summary", None) or item.title
|
||||||
|
|
||||||
|
def item_categories(self, item: BasePage):
|
||||||
|
if tags := getattr(item, "tags", None):
|
||||||
|
return tags.order_by("slug").values_list("slug", flat=True)
|
||||||
|
|
||||||
def item_enclosure_url(self, item: BasePage) -> Optional[str]:
|
def item_enclosure_url(self, item: BasePage) -> Optional[str]:
|
||||||
if not hasattr(item, "get_meta_image_url"):
|
if not hasattr(item, "get_meta_image_url"):
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Reference in a new issue