merge -r46947 from davisagli-features: preserve legacy titles on migrated comments

svn path=/plone.app.discussion/trunk/; revision=48357
This commit is contained in:
David Glick 2011-04-02 21:16:24 +00:00
parent eb004aab44
commit 9d83b4f0e6
3 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,10 @@ Changelog
2.0b1 (Unreleased) 2.0b1 (Unreleased)
------------------ ------------------
- When returning a comment's title, give preference to its title attribute
if set.
[davisagli]
- Use the cooked text of legacy comments when migrating. - Use the cooked text of legacy comments when migrating.
[davisagli] [davisagli]

View File

@ -137,6 +137,10 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
def Title(self): def Title(self):
"""The title of the comment. """The title of the comment.
""" """
if self.title:
return self.title
if not self.creator: if not self.creator:
creator = translate(Message(_(u"label_anonymous", creator = translate(Message(_(u"label_anonymous",
default=u"Anonymous"))) default=u"Anonymous")))

View File

@ -68,7 +68,7 @@ class MigrationTest(PloneTestCase):
self.failUnless(conversation.getComments().next()) self.failUnless(conversation.getComments().next())
comment1 = conversation.values()[0] comment1 = conversation.values()[0]
self.assert_(IComment.providedBy(comment1)) self.assert_(IComment.providedBy(comment1))
self.assertEquals(comment1.Title(), 'Jim on Document 1') self.assertEquals(comment1.Title(), 'My Title')
self.assertEquals(comment1.text, '<p>My Text</p>\n') self.assertEquals(comment1.text, '<p>My Text</p>\n')
self.assertEquals(comment1.mime_type, 'text/html') self.assertEquals(comment1.mime_type, 'text/html')
self.assertEquals(comment1.Creator(), 'Jim') self.assertEquals(comment1.Creator(), 'Jim')