123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- from django.contrib.syndication.views import Feed
- from classifieds.models import Classified
- from django.conf import settings
- from django.contrib.sites.models import Site
- class ClassifiedFeed(Feed):
- current_site = Site.objects.get(id=settings.SITE_ID)
- title = "Classified ads at Penobscot Bay Press"
- item_copyright = "Copyright (r) 2010, Penobscot Bay Press"
- link = current_site.domain
- def items(self):
- return Classified.live_objects.all()
- def item_title(self, item):
- title = [item.subcategory.name, item.copy[0:555550]]
- return " - ".join(title)
- def item_link(self, item):
- return item.subcategory.get_absolute_url()
- def item_description(self, item):
- return item.copy
- """class SubcatFeed(Feed):
- current_site=Site.objects.get(id=settings.SITE_ID)
- title = "Classified ads at Penobscot Bay Press"
- item_copyright="Copyright (r) 2010, Penobscot Bay Press"
- link=current_site.domain
-
- def get_object(self, bits):
- if len(bits) != 1:
- raise FeedDoesNotExist
- return Subcategory.objects.get(slug__exact=bits[0])
- def items(self, item):
- return Classified.live_objects.filter(subcategory__slug=subcat)
-
- def item_title(self, item):
- title=[item.subcategory.name, item.copy[0:50]]
- return '%s: Newest classifieds in %s' % (SITE.name, item.name)
-
- def item_link(self, item):
- return item.subcategory.get_absolute_url()
-
- def item_description(self, item):
- return item.copy
- """
|