Refactor the comment creator/author_name to comply with the Plone core convention to store the username on the creator attribute and not the fullname.
This commit is contained in:
parent
98dca81438
commit
0535e659ff
@ -1,6 +1,15 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
2.2.0 (unreleased)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Refactor the comment creator/author_name to comply with the Plone core
|
||||||
|
convention to store the username on the creator attribute and not the
|
||||||
|
fullname.
|
||||||
|
[timo]
|
||||||
|
|
||||||
|
|
||||||
2.1.8 (unreleased)
|
2.1.8 (unreleased)
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
border="0"
|
border="0"
|
||||||
height="32"
|
height="32"
|
||||||
tal:attributes="src portrait_url;
|
tal:attributes="src portrait_url;
|
||||||
alt reply/Creator" />
|
alt reply/author_name" />
|
||||||
</a>
|
</a>
|
||||||
<img src="defaultUser.gif"
|
<img src="defaultUser.gif"
|
||||||
alt=""
|
alt=""
|
||||||
@ -56,20 +56,20 @@
|
|||||||
height="32"
|
height="32"
|
||||||
tal:condition="not: has_author_link"
|
tal:condition="not: has_author_link"
|
||||||
tal:attributes="src portrait_url;
|
tal:attributes="src portrait_url;
|
||||||
alt reply/Creator" />
|
alt reply/author_name" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="documentByLine" i18n:domain="plone.app.discussion">
|
<div class="documentByLine" i18n:domain="plone.app.discussion">
|
||||||
<tal:name>
|
<tal:name>
|
||||||
<a href=""
|
<a href=""
|
||||||
tal:condition="has_author_link"
|
tal:condition="has_author_link"
|
||||||
tal:content="reply/Creator"
|
tal:content="reply/author_name"
|
||||||
tal:attributes="href author_home_url">
|
tal:attributes="href author_home_url">
|
||||||
Poster Name
|
Poster Name
|
||||||
</a>
|
</a>
|
||||||
<span tal:condition="not: has_author_link"
|
<span tal:condition="not: has_author_link"
|
||||||
tal:replace="reply/Creator" />
|
tal:replace="reply/author_name" />
|
||||||
<span tal:condition="not: reply/Creator">Anonymous</span>
|
<span tal:condition="not: reply/author_name">Anonymous</span>
|
||||||
</tal:name>
|
</tal:name>
|
||||||
<tal:posted i18n:translate="label_says">says:</tal:posted>
|
<tal:posted i18n:translate="label_says">says:</tal:posted>
|
||||||
<div class="commentDate"
|
<div class="commentDate"
|
||||||
|
@ -179,7 +179,6 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
if portal_membership.isAnonymousUser() and \
|
if portal_membership.isAnonymousUser() and \
|
||||||
settings.anonymous_comments:
|
settings.anonymous_comments:
|
||||||
# Anonymous Users
|
# Anonymous Users
|
||||||
comment.creator = author_name
|
|
||||||
comment.author_name = author_name
|
comment.author_name = author_name
|
||||||
comment.author_email = author_email
|
comment.author_email = author_email
|
||||||
comment.user_notification = user_notification
|
comment.user_notification = user_notification
|
||||||
@ -198,7 +197,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
fullname = unicode(fullname, 'utf-8')
|
fullname = unicode(fullname, 'utf-8')
|
||||||
if email and isinstance(email, str):
|
if email and isinstance(email, str):
|
||||||
email = unicode(email, 'utf-8')
|
email = unicode(email, 'utf-8')
|
||||||
comment.creator = fullname
|
comment.creator = username
|
||||||
comment.author_username = username
|
comment.author_username = username
|
||||||
comment.author_name = fullname
|
comment.author_name = fullname
|
||||||
comment.author_email = email
|
comment.author_email = email
|
||||||
|
@ -45,7 +45,7 @@ from OFS.role import RoleManager
|
|||||||
|
|
||||||
COMMENT_TITLE = _(
|
COMMENT_TITLE = _(
|
||||||
u"comment_title",
|
u"comment_title",
|
||||||
default=u"${creator} on ${content}")
|
default=u"${author_name} on ${content}")
|
||||||
|
|
||||||
MAIL_NOTIFICATION_MESSAGE = _(
|
MAIL_NOTIFICATION_MESSAGE = _(
|
||||||
u"mail_notification_message",
|
u"mail_notification_message",
|
||||||
@ -154,19 +154,18 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
|
|||||||
if self.title:
|
if self.title:
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
if not self.creator:
|
if not self.author_name:
|
||||||
creator = translate(Message(_(u"label_anonymous",
|
author_name = translate(Message(_(u"label_anonymous",
|
||||||
default=u"Anonymous")))
|
default=u"Anonymous")))
|
||||||
else:
|
else:
|
||||||
creator = self.creator
|
author_name = self.author_name
|
||||||
creator = creator
|
|
||||||
|
|
||||||
# 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={'author_name': author_name,
|
||||||
'content': safe_unicode(content.Title())}))
|
'content': safe_unicode(content.Title())}))
|
||||||
return title
|
return title
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ class IComment(Interface):
|
|||||||
"email."),
|
"email."),
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
creator = schema.TextLine(title=_(u"Author name (for display)"))
|
creator = schema.TextLine(title=_(u"Username of the commenter"))
|
||||||
creation_date = schema.Date(title=_(u"Creation date"))
|
creation_date = schema.Date(title=_(u"Creation date"))
|
||||||
modification_date = schema.Date(title=_(u"Modification date"))
|
modification_date = schema.Date(title=_(u"Modification date"))
|
||||||
|
|
||||||
|
@ -353,6 +353,7 @@ View the collection listing.
|
|||||||
<Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
|
<Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
|
||||||
>>> browser.getLink('Anonymous on Doc1', index=1)
|
>>> browser.getLink('Anonymous on Doc1', index=1)
|
||||||
<Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
|
<Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
|
||||||
|
>>> open('/tmp/testbrowser.html', 'w').write(browser.contents)
|
||||||
>>> browser.getLink(tarek_fullname + ' on Doc1')
|
>>> browser.getLink(tarek_fullname + ' on Doc1')
|
||||||
<Link text='Tarek Ziad\xc3\xa9 on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
|
<Link text='Tarek Ziad\xc3\xa9 on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
|
||||||
>>> browser.getLink(jim_fullname + ' on Doc1')
|
>>> browser.getLink(jim_fullname + ' on Doc1')
|
||||||
|
@ -63,7 +63,7 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.title = 'Comment 1'
|
comment1.title = 'Comment 1'
|
||||||
comment1.text = 'Comment text'
|
comment1.text = 'Comment text'
|
||||||
comment1.creator = 'Jim'
|
comment1.creator = 'jim'
|
||||||
comment1.author_username = 'Jim'
|
comment1.author_username = 'Jim'
|
||||||
comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||||
comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
|
comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||||
@ -89,7 +89,6 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
comment2.title = 'Comment 2'
|
comment2.title = 'Comment 2'
|
||||||
comment2.text = 'Comment text'
|
comment2.text = 'Comment text'
|
||||||
comment2.creator = 'Emma'
|
|
||||||
new_comment2_id = self.conversation.addComment(comment2)
|
new_comment2_id = self.conversation.addComment(comment2)
|
||||||
|
|
||||||
comment2 = self.portal.doc1.restrictedTraverse(
|
comment2 = self.portal.doc1.restrictedTraverse(
|
||||||
@ -112,7 +111,6 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
comment2.title = 'Comment 2'
|
comment2.title = 'Comment 2'
|
||||||
comment2.text = 'Comment text'
|
comment2.text = 'Comment text'
|
||||||
comment2.creator = 'Emma'
|
|
||||||
comment2.creation_date = datetime(2009, 9, 17, 14, 18, 12)
|
comment2.creation_date = datetime(2009, 9, 17, 14, 18, 12)
|
||||||
comment2.modification_date = datetime(2009, 9, 17, 14, 18, 12)
|
comment2.modification_date = datetime(2009, 9, 17, 14, 18, 12)
|
||||||
new_comment2_id = self.conversation.addComment(comment2)
|
new_comment2_id = self.conversation.addComment(comment2)
|
||||||
@ -159,7 +157,7 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
comment2.title = 'Comment 2'
|
comment2.title = 'Comment 2'
|
||||||
comment2.text = 'Comment text'
|
comment2.text = 'Comment text'
|
||||||
comment2.creator = 'Emma'
|
comment2.creator = 'emma'
|
||||||
comment2.author_username = 'Emma'
|
comment2.author_username = 'Emma'
|
||||||
new_comment2_id = self.conversation.addComment(comment2)
|
new_comment2_id = self.conversation.addComment(comment2)
|
||||||
|
|
||||||
@ -225,7 +223,8 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
|
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = 'Comment text'
|
comment1.text = 'Comment text'
|
||||||
comment1.creator = 'Jim'
|
comment1.creator = 'jim'
|
||||||
|
comment1.author_name = 'Jim'
|
||||||
new_comment1_id = conversation.addComment(comment1)
|
new_comment1_id = conversation.addComment(comment1)
|
||||||
self.comment_id = new_comment1_id
|
self.comment_id = new_comment1_id
|
||||||
|
|
||||||
@ -263,7 +262,7 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
self.assertEqual(self.comment_brain.review_state, 'published')
|
self.assertEqual(self.comment_brain.review_state, 'published')
|
||||||
|
|
||||||
def test_creator(self):
|
def test_creator(self):
|
||||||
self.assertEqual(self.comment_brain.Creator, 'Jim')
|
self.assertEqual(self.comment_brain.Creator, 'jim')
|
||||||
|
|
||||||
def test_in_response_to(self):
|
def test_in_response_to(self):
|
||||||
"""Make sure in_response_to returns the title or id of the content
|
"""Make sure in_response_to returns the title or id of the content
|
||||||
|
@ -98,7 +98,7 @@ class CommentTest(unittest.TestCase):
|
|||||||
def test_title(self):
|
def test_title(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.creator = "Jim Fulton"
|
comment1.author_name = "Jim Fulton"
|
||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
self.assertEqual("Jim Fulton on Document 1", comment1.Title())
|
self.assertEqual("Jim Fulton on Document 1", comment1.Title())
|
||||||
|
|
||||||
@ -114,14 +114,14 @@ class CommentTest(unittest.TestCase):
|
|||||||
type_name='Document')
|
type_name='Document')
|
||||||
conversation = IConversation(self.portal.doc_sp_chars)
|
conversation = IConversation(self.portal.doc_sp_chars)
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.creator = u"Tarek Ziadé"
|
comment1.author_name = u"Tarek Ziadé"
|
||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
self.assertEqual(u"Tarek Ziadé on Document äüö", comment1.Title())
|
self.assertEqual(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"
|
||||||
self.assertEqual("Jim", comment1.Creator())
|
self.assertEqual("jim", comment1.Creator())
|
||||||
|
|
||||||
def test_type(self):
|
def test_type(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
|
@ -49,7 +49,7 @@ class ConversationIndexersTest(unittest.TestCase):
|
|||||||
|
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = 'Comment Text'
|
comment1.text = 'Comment Text'
|
||||||
comment1.creator = "Jim"
|
comment1.creator = "jim"
|
||||||
comment1.author_username = "Jim"
|
comment1.author_username = "Jim"
|
||||||
comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||||
comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
|
comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||||
@ -57,7 +57,7 @@ class ConversationIndexersTest(unittest.TestCase):
|
|||||||
|
|
||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
comment2.text = 'Comment Text'
|
comment2.text = 'Comment Text'
|
||||||
comment2.creator = "Emma"
|
comment2.creator = "emma"
|
||||||
comment2.author_username = "Emma"
|
comment2.author_username = "Emma"
|
||||||
comment2.creation_date = datetime(2007, 12, 13, 4, 18, 12)
|
comment2.creation_date = datetime(2007, 12, 13, 4, 18, 12)
|
||||||
comment2.modification_date = datetime(2007, 12, 13, 4, 18, 12)
|
comment2.modification_date = datetime(2007, 12, 13, 4, 18, 12)
|
||||||
@ -65,7 +65,7 @@ class ConversationIndexersTest(unittest.TestCase):
|
|||||||
|
|
||||||
comment3 = createObject('plone.Comment')
|
comment3 = createObject('plone.Comment')
|
||||||
comment3.text = 'Comment Text'
|
comment3.text = 'Comment Text'
|
||||||
comment3.creator = "Lukas"
|
comment3.creator = "lukas"
|
||||||
comment3.author_username = "Lukas"
|
comment3.author_username = "Lukas"
|
||||||
comment3.creation_date = datetime(2009, 4, 12, 11, 12, 12)
|
comment3.creation_date = datetime(2009, 4, 12, 11, 12, 12)
|
||||||
comment3.modification_date = datetime(2009, 4, 12, 11, 12, 12)
|
comment3.modification_date = datetime(2009, 4, 12, 11, 12, 12)
|
||||||
@ -124,7 +124,8 @@ class CommentIndexersTest(unittest.TestCase):
|
|||||||
|
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Lorem ipsum dolor sit amet.'
|
comment.text = 'Lorem ipsum dolor sit amet.'
|
||||||
comment.creator = "Jim"
|
comment.creator = "jim"
|
||||||
|
comment.author_name = "Jim"
|
||||||
comment.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
comment.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||||
comment.modification_date = datetime(2008, 3, 12, 7, 32, 52)
|
comment.modification_date = datetime(2008, 3, 12, 7, 32, 52)
|
||||||
|
|
||||||
@ -170,7 +171,7 @@ class CommentIndexersTest(unittest.TestCase):
|
|||||||
DelegatingIndexerFactory))
|
DelegatingIndexerFactory))
|
||||||
|
|
||||||
def test_creator(self):
|
def test_creator(self):
|
||||||
self.assertEqual(catalog.creator(self.comment)(), ('Jim'))
|
self.assertEqual(catalog.creator(self.comment)(), ('jim'))
|
||||||
|
|
||||||
def test_in_response_to(self):
|
def test_in_response_to(self):
|
||||||
# make sure in_response_to returns the title or id of the content
|
# make sure in_response_to returns the title or id of the content
|
||||||
|
@ -28,7 +28,8 @@ class ToolTest(unittest.TestCase):
|
|||||||
|
|
||||||
# Add a comment.
|
# Add a comment.
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.creator = 'Jim'
|
comment.creator = 'jim'
|
||||||
|
comment.author_name = "Jim"
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
|
|
||||||
conversation.addComment(comment)
|
conversation.addComment(comment)
|
||||||
|
Loading…
Reference in New Issue
Block a user