Split too complex _enabled_for_archetypes.

This commit is contained in:
Maurits van Rees 2016-06-10 03:40:07 +02:00 committed by Gil Forcada
parent d496dfdddc
commit 1e9909ab6f
2 changed files with 21 additions and 19 deletions

View File

@ -22,6 +22,8 @@ Bug fixes:
Bug fixes:
- Cleaned code from flake8 errors. [maurits]
- Reset the required setting of the author_email widget each time.
Otherwise, the email field might get set to required when an
anonymous user visits, and then remain required when an
@ -29,7 +31,6 @@ Bug fixes:
user to fill in the form without validation error. Or when in the
control panel the field is set as not required anymore, that change
would have no effect until the instance was restarted. [maurits]
- Cleaned code from flake8 errors. [maurits]
2.4.14 (2016-06-06)

View File

@ -19,6 +19,20 @@ except ImportError:
DEXTERITY_INSTALLED = False
def traverse_parents(context):
# Run through the aq_chain of obj and check if discussion is
# enabled in a parent folder.
for obj in aq_chain(context):
if not IPloneSiteRoot.providedBy(obj):
obj_is_folderish = IFolderish.providedBy(obj)
obj_is_stuctural = not INonStructuralFolder.providedBy(obj)
if (obj_is_folderish and obj_is_stuctural):
flag = getattr(obj, 'allow_discussion', None)
if flag is not None:
return flag
return None
class ConversationView(object):
def enabled(self):
@ -31,7 +45,7 @@ class ConversationView(object):
""" Returns True if discussion is enabled for this conversation.
This method checks five different settings in order to figure out if
discussion is enable on a specific content object:
discussion is enabled on a specific content object:
1) Check if discussion is enabled globally in the plone.app.discussion
registry/control panel.
@ -63,23 +77,10 @@ class ConversationView(object):
# Always return False if object is a folder
context_is_folderish = IFolderish.providedBy(context)
context_is_structural = not INonStructuralFolder.providedBy(context)
if (context_is_folderish and context_is_structural):
if context_is_folderish:
if not INonStructuralFolder.providedBy(context):
return False
def traverse_parents(context):
# Run through the aq_chain of obj and check if discussion is
# enabled in a parent folder.
for obj in aq_chain(context):
if not IPloneSiteRoot.providedBy(obj):
obj_is_folderish = IFolderish.providedBy(obj)
obj_is_stuctural = not INonStructuralFolder.providedBy(obj)
if (obj_is_folderish and obj_is_stuctural):
flag = getattr(obj, 'allow_discussion', None)
if flag is not None:
return flag
return None
# If discussion is disabled for the object, bail out
obj_flag = getattr(aq_base(context), 'allow_discussion', None)
if obj_flag is False: