Coverage for posts/feeds.py: 100.00%

17 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-02 19:56 -0700

1import markdown 1a

2from django.contrib.syndication.views import Feed 1a

3from django.template.defaultfilters import truncatewords_html 1a

4from django.urls import reverse_lazy 1a

5 

6from .models import Post 1a

7 

8 

9class LatestPostsFeed(Feed): 1a

10 title = "django-blog" 1a

11 link = reverse_lazy("post_list") 1a

12 description = "Recent posts of django-blog." 1a

13 

14 def items(self): 1a

15 return Post.published.all()[:7] 1b

16 

17 def item_title(self, item): 1a

18 return item.title 1b

19 

20 def item_description(self, item): 1a

21 return truncatewords_html(markdown.markdown(item.body), 30) 1b

22 

23 def item_pubdate(self, item): 1a

24 return item.publish 1b