Use new workflow "visible_states" when required
authorThierry Florac <thierry.florac@onf.fr>
Thu, 10 Jan 2019 17:40:28 +0100
changeset 1223 99a4c33e2962
parent 1222 482e0e1f192f
child 1224 c51128c007d6
Use new workflow "visible_states" when required
src/pyams_content/shared/common/__init__.py
src/pyams_content/shared/common/interfaces/__init__.py
src/pyams_content/shared/common/zmi/header.py
src/pyams_content/shared/site/link.py
src/pyams_content/shared/view/__init__.py
src/pyams_content/shared/view/portlet/__init__.py
--- a/src/pyams_content/shared/common/__init__.py	Thu Jan 10 17:37:38 2019 +0100
+++ b/src/pyams_content/shared/common/__init__.py	Thu Jan 10 17:40:28 2019 +0100
@@ -294,9 +294,9 @@
         return get_parent(self, IBaseSharedTool).shared_content_workflow
 
     @volatile_property
-    def published_version(self):
+    def visible_version(self):
         workflow = IWorkflow(self)
-        versions = IWorkflowVersions(self).get_versions(workflow.published_states, sort=True)
+        versions = IWorkflowVersions(self).get_versions(workflow.visible_states, sort=True)
         if versions:
             return versions[-1]
 
@@ -326,4 +326,4 @@
     """Reste target on workflow transition"""
     content = get_parent(event.object, ISharedContent)
     if content is not None:
-        del content.published_version
+        del content.visible_version
--- a/src/pyams_content/shared/common/interfaces/__init__.py	Thu Jan 10 17:37:38 2019 +0100
+++ b/src/pyams_content/shared/common/interfaces/__init__.py	Thu Jan 10 17:40:28 2019 +0100
@@ -225,7 +225,7 @@
 class ISharedContent(IWorkflowManagedContent):
     """Workflow managed shared content interface"""
 
-    published_version = Attribute("Link to actually published version")
+    visible_version = Attribute("Link to actually visible version")
 
 
 class ISharedContentFactory(Interface):
--- a/src/pyams_content/shared/common/zmi/header.py	Thu Jan 10 17:37:38 2019 +0100
+++ b/src/pyams_content/shared/common/zmi/header.py	Thu Jan 10 17:40:28 2019 +0100
@@ -112,14 +112,14 @@
         self.state_date = translate(_("since {date}")).format(date=format_datetime(state.state_date, request=request))
         # check for links to other versions
         links = []
-        published_versions = sorted(versions.get_versions(workflow.published_states),
-                                    key=lambda x: IWorkflowState(x).version_id)
+        visible_versions = sorted(versions.get_versions(workflow.visible_states),
+                                  key=lambda x: IWorkflowState(x).version_id)
         draft_versions = sorted(versions.get_versions(workflow.update_states),
                                 key=lambda x: IWorkflowState(x).version_id)
         if (state.version_id > 1) or (state.state != workflow.initial_state):
             targets = set()
-            if published_versions:
-                target = published_versions[0]
+            if visible_versions:
+                target = visible_versions[0]
                 if (target is not context) and (target not in targets):
                     links.append({'title': translate(_("access published version")),
                                   'href': absolute_url(target, request, 'admin'),
--- a/src/pyams_content/shared/site/link.py	Thu Jan 10 17:37:38 2019 +0100
+++ b/src/pyams_content/shared/site/link.py	Thu Jan 10 17:40:28 2019 +0100
@@ -66,7 +66,7 @@
         if IWorkflowVersion.providedBy(target):
             workflow = IWorkflow(target, None)
             if workflow is not None:
-                versions = IWorkflowVersions(target).get_versions(workflow.published_states, sort=True)
+                versions = IWorkflowVersions(target).get_versions(workflow.visible_states, sort=True)
                 if not versions:
                     versions = IWorkflowVersions(target).get_last_versions()
                 if versions:
--- a/src/pyams_content/shared/view/__init__.py	Thu Jan 10 17:37:38 2019 +0100
+++ b/src/pyams_content/shared/view/__init__.py	Thu Jan 10 17:40:28 2019 +0100
@@ -9,9 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from copy import deepcopy
-
-from jedi.evaluate.helpers import deep_ast_copy
 
 __docformat__ = 'restructuredtext'
 
@@ -185,7 +182,7 @@
         # check workflow states
         wf_params = None
         for workflow in registry.getAllUtilitiesRegisteredFor(IWorkflow):
-            wf_params = or_(wf_params, Any(catalog['workflow_state'], workflow.published_states))
+            wf_params = or_(wf_params, Any(catalog['workflow_state'], workflow.visible_states))
         params &= wf_params
         # check custom extensions
         do_search = True
--- a/src/pyams_content/shared/view/portlet/__init__.py	Thu Jan 10 17:37:38 2019 +0100
+++ b/src/pyams_content/shared/view/portlet/__init__.py	Thu Jan 10 17:40:28 2019 +0100
@@ -53,7 +53,7 @@
         views_manager = get_utility(IViewsManager)
         workflow = IWorkflow(views_manager)
         for oid in self.views or ():
-            view = get_sequence_target(oid, state=workflow.published_states)
+            view = get_sequence_target(oid, state=workflow.visible_states)
             if view is not None:
                 yield view