From 360a758905cf27817f34612ad860d8b460ee0d5d Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Tue, 7 Jul 2009 14:48:39 +0000 Subject: [PATCH] fix that enabled method check for FTI information of the current content object and not only for the "Document" portal_type. svn path=/plone.app.discussion/trunk/; revision=27889 --- plone/app/discussion/conversation.py | 2 +- .../app/discussion/tests/test_conversation.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index 02fe54d..a02a8a9 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -145,7 +145,7 @@ class Conversation(Traversable, Persistent, Explicit): # Check if discussion is allowed on the content type portal_type = self.__parent__.portal_type - document_fti = getattr(portal_types, 'Document') + document_fti = getattr(portal_types, obj.portal_type) if not document_fti.getProperty('allow_discussion'): # If discussion is not allowed on the content type, # check if 'allow discussion' is overridden on the content object. diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index 291e74c..e5f6c27 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -230,6 +230,33 @@ class ConversationTest(PloneTestCase): self.assertEquals(conversation.enabled(), True) + def test_allow_discussion_for_news_items(self): + + self.typetool.constructContent('News Item', self.portal, 'newsitem') + newsitem = self.portal.newsitem + conversation = IConversation(newsitem) + + # 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, 'News Item') + document_fti.manage_changeProperties(allow_discussion = True) + + # Check if conversation is enabled now + self.assertEquals(conversation.enabled(), True) + + # Disable commenting in the registry + registry = queryUtility(IRegistry) + settings = registry.for_interface(IDiscussionSettings) + settings.globally_enabled = False + + # Check if commenting is disabled on the conversation + self.assertEquals(conversation.enabled(), False) + + # Enable discussion again + settings.globally_enabled = True + self.assertEquals(conversation.enabled(), True) + def test_disable_commenting_for_content_type(self): # Create a conversation.