From 9f4129a65f1abc7ac15c63c8c77eb3790541a9d0 Mon Sep 17 00:00:00 2001 From: Hanno Schlichting Date: Wed, 27 Jan 2010 17:00:58 +0000 Subject: [PATCH] Respect the allow_comments field on an object and avoid calculations if no comments should be shown. svn path=/plone.app.discussion/trunk/; revision=33511 --- docs/HISTORY.txt | 1 + plone/app/discussion/browser/comments.pt | 9 +++++---- plone/app/discussion/conversation.py | 10 ++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index eb4c1b5..8c5e1c0 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -4,6 +4,7 @@ Changelog 1.0b3 (XXXX-XX-XX) ------------------ +* Respect the allow_comments field on an object and avoid calculations if no comments should be shown. [hannosch] * Automatically load the ZCML files of the captcha widgets if they are installed. [hannosch] * Fixed i18n domain in GenericSetup profiles to be ``plone``. Other values aren't supported for GS profiles. [hannosch] * Provide our own copy of the default one state workflow. Not all Plone sites have this workflow installed. [hannosch] diff --git a/plone/app/discussion/browser/comments.pt b/plone/app/discussion/browser/comments.pt index dd82c51..b109991 100644 --- a/plone/app/discussion/browser/comments.pt +++ b/plone/app/discussion/browser/comments.pt @@ -1,5 +1,7 @@ + + wtool context/@@plone_tools/workflow;">
@@ -154,4 +154,5 @@
+
\ No newline at end of file diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index 8c47c00..c07540e 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -125,13 +125,19 @@ class Conversation(Traversable, Persistent, Explicit): obj = aq_parent(self) + # If discussion is disabled for the object, bail out + allow_discussion_flag = getattr(obj, 'allow_discussion', None) + if allow_discussion_flag is False: + return False + # Check if traversal returned a folder with discussion_allowed set # to True or False. folder_allow_discussion = traverse_parents(obj) - if folder_allow_discussion == True: + + if folder_allow_discussion is True: if not getattr(self, 'allow_discussion', None): return True - elif folder_allow_discussion == False: + elif folder_allow_discussion is False: if getattr(aq_inner(self.__parent__), 'allow_discussion', None): return True