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.
|
"""The default comment class and factory.
|
||||||
"""
|
"""
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -47,7 +48,7 @@ except:
|
|||||||
PLONE_4 = False
|
PLONE_4 = False
|
||||||
|
|
||||||
COMMENT_TITLE = _(u"comment_title",
|
COMMENT_TITLE = _(u"comment_title",
|
||||||
default=u"${creator} on ${content}")
|
default=u"${creator} on ${content}")
|
||||||
|
|
||||||
MAIL_NOTIFICATION_MESSAGE = _(u"mail_notification_message",
|
MAIL_NOTIFICATION_MESSAGE = _(u"mail_notification_message",
|
||||||
default=u"A comment with the title '${title}' "
|
default=u"A comment with the title '${title}' "
|
||||||
@ -118,21 +119,20 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
|
|||||||
def Title(self):
|
def Title(self):
|
||||||
"""The title of the comment.
|
"""The title of the comment.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.creator:
|
if not self.creator:
|
||||||
creator = _(u"label_anonymous",
|
creator = translate(Message(_(u"label_anonymous",
|
||||||
default=u"Anonymous")
|
default=u"Anonymous")))
|
||||||
else:
|
else:
|
||||||
creator = self.creator
|
creator = self.creator
|
||||||
|
creator = creator.decode("utf-8")
|
||||||
|
|
||||||
# Fetch the content object (the parent of the comment is the
|
# Fetch the content object (the parent of the comment is the
|
||||||
# conversation, the parent of the conversation is the content object).
|
# conversation, the parent of the conversation is the content object).
|
||||||
content = aq_base(self.__parent__.__parent__)
|
content = aq_base(self.__parent__.__parent__)
|
||||||
|
|
||||||
title = translate(
|
title = translate(
|
||||||
Message(COMMENT_TITLE,
|
Message(COMMENT_TITLE,
|
||||||
mapping={'creator': creator,
|
mapping={'creator': creator,
|
||||||
'content': content.Title()}))
|
'content': content.Title().decode("utf-8")}))
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def Creator(self):
|
def Creator(self):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -72,6 +73,16 @@ class CommentTest(PloneTestCase):
|
|||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
self.assertEquals("Anonymous on Document 1", comment1.Title())
|
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):
|
def test_creator(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.creator = "Jim"
|
comment1.creator = "Jim"
|
||||||
|
Loading…
Reference in New Issue
Block a user