Fixed #14202 -- made the atom:link element optional in feeds.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17029 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
59c051d170
commit
965c5d7cce
|
@ -224,7 +224,9 @@ class RssFeed(SyndicationFeed):
|
||||||
handler.addQuickElement(u"title", self.feed['title'])
|
handler.addQuickElement(u"title", self.feed['title'])
|
||||||
handler.addQuickElement(u"link", self.feed['link'])
|
handler.addQuickElement(u"link", self.feed['link'])
|
||||||
handler.addQuickElement(u"description", self.feed['description'])
|
handler.addQuickElement(u"description", self.feed['description'])
|
||||||
handler.addQuickElement(u"atom:link", None, {u"rel": u"self", u"href": self.feed['feed_url']})
|
if self.feed['feed_url'] is not None:
|
||||||
|
handler.addQuickElement(u"atom:link", None,
|
||||||
|
{u"rel": u"self", u"href": self.feed['feed_url']})
|
||||||
if self.feed['language'] is not None:
|
if self.feed['language'] is not None:
|
||||||
handler.addQuickElement(u"language", self.feed['language'])
|
handler.addQuickElement(u"language", self.feed['language'])
|
||||||
for cat in self.feed['categories']:
|
for cat in self.feed['categories']:
|
||||||
|
|
|
@ -87,3 +87,16 @@ class FeedgeneratorTest(unittest.TestCase):
|
||||||
atom_feed.mime_type, "application/atom+xml; charset=utf-8"
|
atom_feed.mime_type, "application/atom+xml; charset=utf-8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Two regression tests for #14202
|
||||||
|
|
||||||
|
def test_feed_without_feed_url_gets_rendered_without_atom_link(self):
|
||||||
|
feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr')
|
||||||
|
self.assertEquals(feed.feed['feed_url'], None)
|
||||||
|
feed_content = feed.writeString('utf-8')
|
||||||
|
self.assertNotIn('<atom:link href=', feed_content)
|
||||||
|
|
||||||
|
def test_feed_with_feed_url_gets_rendered_with_atom_link(self):
|
||||||
|
feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr', feed_url='/feed/')
|
||||||
|
self.assertEquals(feed.feed['feed_url'], '/feed/')
|
||||||
|
feed_content = feed.writeString('utf-8')
|
||||||
|
self.assertIn('<atom:link href="/feed/" rel="self"></atom:link>', feed_content)
|
||||||
|
|
Loading…
Reference in New Issue