Make sure comment titles work with special characters as well.
svn path=/plone.app.discussion/trunk/; revision=40486
This commit is contained in:
parent
51d6c60412
commit
e0055d0ba7
@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""The default comment class and factory.
|
||||
"""
|
||||
from datetime import datetime
|
||||
@ -118,21 +119,20 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
|
||||
def Title(self):
|
||||
"""The title of the comment.
|
||||
"""
|
||||
|
||||
if not self.creator:
|
||||
creator = _(u"label_anonymous",
|
||||
default=u"Anonymous")
|
||||
creator = translate(Message(_(u"label_anonymous",
|
||||
default=u"Anonymous")))
|
||||
else:
|
||||
creator = self.creator
|
||||
creator = creator.decode("utf-8")
|
||||
|
||||
# Fetch the content object (the parent of the comment is the
|
||||
# conversation, the parent of the conversation is the content object).
|
||||
content = aq_base(self.__parent__.__parent__)
|
||||
|
||||
title = translate(
|
||||
Message(COMMENT_TITLE,
|
||||
mapping={'creator': creator,
|
||||
'content': content.Title()}))
|
||||
'content': content.Title().decode("utf-8")}))
|
||||
return title
|
||||
|
||||
def Creator(self):
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
|
||||
import logging
|
||||
@ -72,6 +73,16 @@ class CommentTest(PloneTestCase):
|
||||
conversation.addComment(comment1)
|
||||
self.assertEquals("Anonymous on Document 1", comment1.Title())
|
||||
|
||||
def test_title_special_characters(self):
|
||||
self.portal.invokeFactory(id='doc_sp_chars',
|
||||
title='Document äüö',
|
||||
type_name='Document')
|
||||
conversation = IConversation(self.portal.doc_sp_chars)
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.creator = "Tarek Ziadé"
|
||||
conversation.addComment(comment1)
|
||||
self.assertEquals(u"Tarek Ziadé on Document äüö", comment1.Title())
|
||||
|
||||
def test_creator(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.creator = "Jim"
|
||||
|
Loading…
Reference in New Issue
Block a user