# HG changeset patch # User Thierry Florac # Date 1512397602 -3600 # Node ID caa4dfcc51ee292d41000bfd1e821960b37925cb # Parent 31cbce6cb8641f046151b36e2a9508ca5dd5f2cd Add option to not check parent in "get_published" / "get_visible" methods diff -r 31cbce6cb864 -r caa4dfcc51ee src/pyams_workflow/content.py --- a/src/pyams_workflow/content.py Sun Nov 26 10:17:30 2017 +0100 +++ b/src/pyams_workflow/content.py Mon Dec 04 15:26:42 2017 +0100 @@ -154,11 +154,12 @@ self._publication_expiration_date = None self.push_end_date = None - def is_published(self): + def is_published(self, check_parent=True): # check is parent is published - parent = get_parent(self.__parent__, IWorkflowPublicationSupport, allow_context=False) - if (parent is not None) and not IWorkflowPublicationInfo(parent).is_published(): - return False + if check_parent: + parent = get_parent(self.__parent__, IWorkflowPublicationSupport, allow_context=False) + if (parent is not None) and not IWorkflowPublicationInfo(parent).is_published(): + return False # associated workflow? workflow = IWorkflow(self.__parent__, None) if (workflow is not None) and not workflow.published_states: @@ -173,7 +174,7 @@ ((self.publication_expiration_date is None) or (self.publication_expiration_date >= now)) - def is_visible(self, request=None): + def is_visible(self, request=None, check_parent=True): # associated workflow? content = IWorkflowManagedContent(self.__parent__, None) if content is not None: @@ -189,7 +190,7 @@ else: if not request.has_permission(VIEW_PERMISSION, context=self.__parent__): return False - return self.is_published() + return self.is_published(check_parent) WORKFLOW_CONTENT_KEY = 'pyams_workflow.content_info' diff -r 31cbce6cb864 -r caa4dfcc51ee src/pyams_workflow/interfaces/__init__.py --- a/src/pyams_workflow/interfaces/__init__.py Sun Nov 26 10:17:30 2017 +0100 +++ b/src/pyams_workflow/interfaces/__init__.py Mon Dec 04 15:26:42 2017 +0100 @@ -467,10 +467,10 @@ def reset(self): """Reset all publication info (used by clone features)""" - def is_published(self): + def is_published(self, check_parent=True): """Is the content published?""" - def is_visible(self, request=None): + def is_visible(self, request=None, check_parent=True): """Is the content visible?"""