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
This commit is contained in:
Hanno Schlichting 2010-01-27 17:00:58 +00:00
parent 034d0a93ad
commit 9f4129a65f
3 changed files with 14 additions and 6 deletions

View File

@ -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]

View File

@ -1,5 +1,7 @@
<tal:block tal:define="isDiscussionAllowed view/is_discussion_allowed"
tal:condition="isDiscussionAllowed"
i18n:domain="plone">
<tal:block define="userHasReplyPermission view/can_reply;
isDiscussionAllowed view/is_discussion_allowed;
isAnonymousDiscussionAllowed view/anonymous_discussion_allowed;
isAnon view/is_anonymous;
canManage view/can_manage;
@ -7,9 +9,7 @@
has_replies python:view.has_replies(canManage);
showCommenterImage view/show_commenter_image;
errors options/state/getErrors|nothing;
wtool context/@@plone_tools/workflow"
tal:condition="isDiscussionAllowed"
i18n:domain="plone">
wtool context/@@plone_tools/workflow;">
<div class="reply"
tal:condition="python:isAnon and not isAnonymousDiscussionAllowed">
@ -155,3 +155,4 @@
</div>
</tal:block>
</tal:block>

View File

@ -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