from django.contrib.syndication.views import Feed from newsroom.models import Story from django.conf import settings from django.contrib.sites.models import Site class LatestNewsFeed(Feed): current_site = Site.objects.get(id=settings.SITE_ID) title = current_site.name + " news" link = current_site.domain item_copyright = "Copyright (r) 2010, Penobscot Bay Press" if current_site.name == "penobscotbaypress.com": description = "News from the Blue Hill Peninsula and Deer Isle in Maine." elif current_site.name == "castinepatriot.com": description = "News from around Castine and Penobscot, Maine." elif current_site.name == "islandadvantages.com": description = "News from around Deer Isle and Stonington, Maine." elif current_site.name == "weeklypacket.com": description = "News from around the towns of the Blue Hill Peninsula Maine." def items(self): if self.current_site.name == "penobscotbaypress.com": return ( Story.objects.published() .exclude(sites__name="castinepatriot.com") .exclude(sites__name="weeklypacket.com") .exclude(sites__name="islandadvantages.com") ) else: return Story.objects.published()[:30] def item_author_name(self, item): return " & ".join(["%s" % (a) for a in item.authors.all()]) def item_pubdate(self, item): return item.published_on def item_title(self, item): return item.web_hed def item_link(self, item): return item.get_absolute_url() def item_description(self, item): return item.summary