Changed header to remove link to "new version" when the only content version is in "retired" state
authorThierry Florac <thierry.florac@onf.fr>
Wed, 12 Jul 2017 11:48:01 +0200
changeset 106 b82200b101a9
parent 105 338c87104ede
child 107 b41cf853ff8c
Changed header to remove link to "new version" when the only content version is in "retired" state
src/pyams_content/shared/common/zmi/header.py
--- a/src/pyams_content/shared/common/zmi/header.py	Wed Jul 12 11:46:22 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/header.py	Wed Jul 12 11:48:01 2017 +0200
@@ -111,11 +111,14 @@
            (state.state in workflow.retired_states and has_update_state):
             target = sorted(versions.get_versions(workflow.update_states),
                             key=lambda x: IWorkflowState(x).version_id)[-1]
-            self.version_link = {
-                'css_class': 'text-danger',
-                'href': absolute_url(target, request, 'admin'),
-                'title': translate(_("access new version"))
-            }
+            if target is not context:
+                self.version_link = {
+                    'css_class': 'text-danger',
+                    'href': absolute_url(target, request, 'admin'),
+                    'title': translate(_("access new version"))
+                }
+            else:
+                self.version_link = None
         elif state.state not in workflow.published_states and versions.has_version(workflow.published_states):
             target = sorted(versions.get_versions(workflow.published_states),
                             key=lambda x: IWorkflowState(x).version_id,