feeds.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 (
  21. Story.objects.published()
  22. .exclude(sites__name="castinepatriot.com")
  23. .exclude(sites__name="weeklypacket.com")
  24. .exclude(sites__name="islandadvantages.com")
  25. )
  26. else:
  27. return Story.objects.published()[:30]
  28. def item_author_name(self, item):
  29. return " & ".join(["%s" % (a) for a in item.authors.all()])
  30. def item_pubdate(self, item):
  31. return item.published_on
  32. def item_title(self, item):
  33. return item.web_hed
  34. def item_link(self, item):
  35. return item.get_absolute_url()
  36. def item_description(self, item):
  37. return item.summary