From 34dcf63a93a5da8e413c79e7c0635f25b883dc67 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 29 Nov 2023 14:30:13 +0000 Subject: [PATCH] Add tags to feed --- website/blog/tests.py | 2 +- website/common/views.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/website/blog/tests.py b/website/blog/tests.py index 4bacc0a..6a231d2 100644 --- a/website/blog/tests.py +++ b/website/blog/tests.py @@ -80,7 +80,7 @@ class BlogPostListPageTestCase(TestCase): self.client.get(self.page.url) def test_feed_accessible(self) -> None: - with self.assertNumQueries(12): + with self.assertNumQueries(14): response = self.client.get( self.page.url + self.page.reverse_subpage("feed") ) diff --git a/website/common/views.py b/website/common/views.py index 5e4218e..e9a5079 100644 --- a/website/common/views.py +++ b/website/common/views.py @@ -114,7 +114,7 @@ class AllPagesFeed(Feed): return item.get_full_url(request=self.request) + "?utm_medium=rss" 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 item.first_published_at @@ -124,6 +124,10 @@ class AllPagesFeed(Feed): def item_description(self, item: BasePage) -> str: 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]: if not hasattr(item, "get_meta_image_url"): return ""