from django.core.urlresolvers import reverse
from django.contrib.syndication.feeds import Feed
from djournal.models import Entry
from djournal.settings import DJOURNAL_BLOG_TITLE
from django.core.exceptions import ObjectDoesNotExist
from tagging.models import Tag
from tagging.utils import get_tag
class EntryFeed(Feed) :
title = DJOURNAL_BLOG_TITLE
link = "/"
description = u"All about everything."
title_template = 'feeds/title.html'
description_template = 'feeds/description.html'
def items(self) :
return Entry.live.order_by('-creation_timestamp')
class EntryRstFeed(EntryFeed) :
description_template = 'feeds/description_rst.html'
class TagEntryFeed(Feed) :
def get_object(self, bits) :
print bits
if len(bits) != 1 :
raise ObjectDoesNotExist
TagObject = get_tag(bits[0])
if not TagObject :
raise ObjectDoesNotExist
print TagObject.name
return TagObject
def title(self, tag) :
return u"%s : Entries tagged with %s" % (DJOURNAL_BLOG_TITLE, tag.name)
def description(self, tag) :
return "Entries tagged with %s" % tag.name
def items(self, tag) :
return Entry.tagged.with_all([tag]).filter(status = 'live').order_by('-creation_timestamp')
def link(self, tag) :
return reverse('djournal_tag_listing', kwargs = {'tag' : tag.name})
title_template = 'feeds/title.html'
description_template = 'feeds/description.html'
class TagEntryRstFeed(TagEntryFeed) :
description_template = 'feeds/description_rst.html'