from django.contrib.syndication.views import Feed

from ..models import Post

class PostRSSFeedView(Feed):
    title = "Luxagraf: Topographical Writings"
    link = "https://luxagraf.net/"
    description = "Latest postings to luxagraf.net"
    description_template = 'feeds/blog_description.html'

    def items(self):
        return Post.objects.filter(status__exact=1).order_by('-pub_date')[:10]
    
    def item_pubdate(self, item):
        """
        Takes an item, as returned by items(), and returns the item's
        pubdate.
        """
        return item.pub_date