feeds.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from django.contrib.syndication.views import Feed
  2. from classifieds.models import Classified
  3. from django.conf import settings
  4. from django.contrib.sites.models import Site
  5. class ClassifiedFeed(Feed):
  6. current_site = Site.objects.get(id=settings.SITE_ID)
  7. title = "Classified ads at Penobscot Bay Press"
  8. item_copyright = "Copyright (r) 2010, Penobscot Bay Press"
  9. link = current_site.domain
  10. def items(self):
  11. return Classified.live_objects.all()
  12. def item_title(self, item):
  13. title = [item.subcategory.name, item.copy[0:555550]]
  14. return " - ".join(title)
  15. def item_link(self, item):
  16. return item.subcategory.get_absolute_url()
  17. def item_description(self, item):
  18. return item.copy
  19. """class SubcatFeed(Feed):
  20. current_site=Site.objects.get(id=settings.SITE_ID)
  21. title = "Classified ads at Penobscot Bay Press"
  22. item_copyright="Copyright (r) 2010, Penobscot Bay Press"
  23. link=current_site.domain
  24. def get_object(self, bits):
  25. if len(bits) != 1:
  26. raise FeedDoesNotExist
  27. return Subcategory.objects.get(slug__exact=bits[0])
  28. def items(self, item):
  29. return Classified.live_objects.filter(subcategory__slug=subcat)
  30. def item_title(self, item):
  31. title=[item.subcategory.name, item.copy[0:50]]
  32. return '%s: Newest classifieds in %s' % (SITE.name, item.name)
  33. def item_link(self, item):
  34. return item.subcategory.get_absolute_url()
  35. def item_description(self, item):
  36. return item.copy
  37. """