Fixed the case where a folder has allow_discussion=False and

conversation.enabled() on a document in this folder returned False
instead of True because of allow_discussion acquisition.

svn path=/plone.app.discussion/trunk/; revision=38835
This commit is contained in:
Vincent Fretin 2010-08-20 11:52:05 +00:00
parent 01bc4a778a
commit 352a517a0a
3 changed files with 32 additions and 2 deletions

View File

@ -4,6 +4,11 @@ Changelog
1.0b6 (unreleased)
------------------
* Fixed the case where a folder has allow_discussion=False and
conversation.enabled() on a document in this folder returned False
instead of True because of allow_discussion acquisition.
[vincentfretin]
* Redirect to the comment form action instead of the absolute url when a
comment is posted. This fixes the accidentially triggered file upload when a
comment is posted on a file content object.

View File

@ -127,7 +127,7 @@ class Conversation(Traversable, Persistent, Explicit):
obj = aq_parent(self)
# If discussion is disabled for the object, bail out
obj_flag = getattr(obj, 'allow_discussion', None)
obj_flag = getattr(aq_base(obj), 'allow_discussion', None)
if obj_flag is False:
return False

View File

@ -215,6 +215,31 @@ class ConversationTest(PloneTestCase):
self.assertEquals(portal_discussion.isDiscussionAllowedFor(self.portal.doc1), True)
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None), True)
def test_comments_enabled_on_doc_in_subfolder(self):
typetool = self.portal.portal_types
typetool.constructContent('Folder', self.portal, 'folder1')
typetool.constructContent('Document', self.portal.folder1, 'doc2')
folder = self.portal.folder1
folder.allowDiscussion(False)
self.assertFalse(hasattr(aq_base(folder), 'allow_discussion'))
folder.allowDiscussion(True)
self.assertTrue(aq_base(folder).allow_discussion)
folder.allowDiscussion(False)
self.assertFalse(aq_base(folder).allow_discussion)
doc = self.portal.folder1.doc2
conversation = IConversation(doc)
self.assertEquals(conversation.enabled(), False)
# We have to allow discussion on Document content type, since
# otherwise allow_discussion will always return False
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'Document')
document_fti.manage_changeProperties(allow_discussion = True)
self.assertEquals(conversation.enabled(), True)
def test_disable_commenting_globally(self):
# Create a conversation.