feeds.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from django.contrib.syndication.views import Feed
  2. from newsroom.models import Story
  3. from django.conf import settings
  4. from django.contrib.sites.models import Site
  5. class LatestNewsFeed(Feed):
  6. current_site = Site.objects.get(id=settings.SITE_ID)
  7. title = current_site.name + " news"
  8. link = current_site.domain
  9. item_copyright="Copyright (r) 2010, Penobscot Bay Press"
  10. if current_site.name == "penobscotbaypress.com":
  11. description = "News from the Blue Hill Peninsula and Deer Isle in Maine."
  12. elif current_site.name == "castinepatriot.com":
  13. description = "News from around Castine and Penobscot, Maine."
  14. elif current_site.name == "islandadvantages.com":
  15. description = "News from around Deer Isle and Stonington, Maine."
  16. elif current_site.name == "weeklypacket.com":
  17. description = "News from around the towns of the Blue Hill Peninsula Maine."
  18. def items(self):
  19. if self.current_site.name == "penobscotbaypress.com":
  20. return Story.objects.published().exclude(sites__name="castinepatriot.com").exclude(sites__name="weeklypacket.com").exclude(sites__name="islandadvantages.com")
  21. else:
  22. return Story.objects.published()[:30]
  23. def item_author_name(self, item):
  24. return " & ".join(["%s" % (a) for a in item.authors.all()])
  25. def item_pubdate(self, item):
  26. return item.published_on
  27. def item_title(self, item):
  28. return item.web_hed
  29. def item_link(self, item):
  30. return item.get_absolute_url()
  31. def item_description(self, item):
  32. return item.summary