Changed reversed links view module
authorThierry Florac <tflorac@ulthar.net>
Fri, 20 Jul 2018 00:41:18 +0200
changeset 870 8c8a8ce8e0c2
parent 869 ae7f0471e337
child 871 d7ad1624cc4f
Changed reversed links view module
src/pyams_content/component/links/zmi/reverse.py
src/pyams_content/shared/common/zmi/reverse.py
--- a/src/pyams_content/component/links/zmi/reverse.py	Thu Jul 19 22:15:47 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-from hypatia.interfaces import ICatalog
-from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable
-from pyams_content.shared.site.interfaces import ISiteContainer
-from pyams_portal.interfaces import IPortalTemplate
-from pyams_sequence.interfaces import ISequentialIdInfo
-from pyams_skin.interfaces import IInnerPage
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_workflow.interfaces import IWorkflowVersions
-from pyams_zmi.interfaces.menu import IContentManagementMenu
-from pyams_zmi.layer import IAdminLayer
-from z3c.table.interfaces import IValues, IColumn
-
-# import packages
-from hypatia.catalog import CatalogQuery
-from hypatia.query import Eq, Or
-from pyams_catalog.query import CatalogResultSet
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_skin.container import ContainerView
-from pyams_skin.table import BaseTable, NameColumn
-from pyams_skin.viewlet.menu import MenuItem
-from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
-from pyams_utils.list import unique
-from pyams_utils.registry import get_utility
-from pyams_utils.traversing import get_parent
-from pyams_viewlet.viewlet import viewlet_config
-from pyams_zmi.view import AdminView
-from zope.interface import implementer, Interface
-
-from pyams_content import _
-
-
-@viewlet_config(name='reverse-links.menu', context=IWfSharedContent, layer=IAdminLayer,
-                manager=IContentManagementMenu, permission=VIEW_SYSTEM_PERMISSION, weight=40)
-class SequentialITargetReverseLinksMenu(MenuItem):
-    """Sequential ID target reverse links menu"""
-
-    label = _("Reverse links")
-    icon_class = 'fa-anchor'
-    url = '#reverse-links.html'
-
-
-@implementer(ISiteRootDashboardTable)
-class SequentialIdTargetReverseLinkTable(BaseTable):
-    """Sequential ID target reverse links table"""
-
-    title = _("Content's internal links")
-
-
-@adapter_config(name='name', context=(Interface, IPyAMSLayer, SequentialIdTargetReverseLinkTable), provides=IColumn)
-class ReverseLinkNameColumn(NameColumn):
-    """Reverse link name column"""
-
-    _header = _("Title")
-
-
-@adapter_config(context=(IWfSharedContent, IPyAMSLayer, SequentialIdTargetReverseLinkTable), provides=IValues)
-class SequentialIdTargetReverseLinkValues(ContextRequestViewAdapter):
-    """Sequential ID target reverse links values"""
-
-    @property
-    def values(self):
-
-        def get_item(result):
-            parent = get_parent(result, IWfSharedContent)
-            if parent is not None:
-                return IWorkflowVersions(parent).get_last_versions(count=1)[0]
-            parent = get_parent(result, IPortalTemplate)
-            if parent is None:
-                parent = get_parent(result, ISiteContainer)
-            if parent is None:
-                parent = self.request.root
-            return parent
-
-        catalog = get_utility(ICatalog)
-        oid = ISequentialIdInfo(self.context).hex_oid
-        params = Or(Eq(catalog['link_reference'], oid),
-                    Eq(catalog['link_references'], oid))
-        return unique(map(get_item,
-                          CatalogResultSet(CatalogQuery(catalog).query(params,
-                                                                       sort_index='modified_date'))))
-
-
-@pagelet_config(name='reverse-links.html', context=IWfSharedContent, layer=IPyAMSLayer,
-                permission=VIEW_SYSTEM_PERMISSION)
-@implementer(IInnerPage)
-class SequentialIdTargetReverseLinkView(AdminView, ContainerView):
-    """Sequential ID target reverse links view"""
-
-    table_class = SequentialIdTargetReverseLinkTable
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/common/zmi/reverse.py	Fri Jul 20 00:41:18 2018 +0200
@@ -0,0 +1,109 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from hypatia.interfaces import ICatalog
+from pyams_content.shared.common.interfaces import IWfSharedContent
+from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable
+from pyams_content.shared.site.interfaces import ISiteContainer
+from pyams_portal.interfaces import IPortalTemplate
+from pyams_sequence.interfaces import ISequentialIdInfo
+from pyams_skin.interfaces import IInnerPage
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_workflow.interfaces import IWorkflowVersions
+from pyams_zmi.interfaces.menu import IContentManagementMenu
+from pyams_zmi.layer import IAdminLayer
+from z3c.table.interfaces import IValues, IColumn
+
+# import packages
+from hypatia.catalog import CatalogQuery
+from hypatia.query import Eq, Or
+from pyams_catalog.query import CatalogResultSet
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.container import ContainerView
+from pyams_skin.table import BaseTable, NameColumn
+from pyams_skin.viewlet.menu import MenuItem
+from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
+from pyams_utils.list import unique_iter
+from pyams_utils.registry import get_utility
+from pyams_utils.traversing import get_parent
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.view import AdminView
+from zope.interface import implementer, Interface
+
+from pyams_content import _
+
+
+@viewlet_config(name='reverse-links.menu', context=IWfSharedContent, layer=IAdminLayer,
+                manager=IContentManagementMenu, permission=VIEW_SYSTEM_PERMISSION, weight=40)
+class SequentialITargetReverseLinksMenu(MenuItem):
+    """Sequential ID target reverse links menu"""
+
+    label = _("Reverse links")
+    icon_class = 'fa-anchor'
+    url = '#reverse-links.html'
+
+
+@implementer(ISiteRootDashboardTable)
+class SequentialIdTargetReverseLinkTable(BaseTable):
+    """Sequential ID target reverse links table"""
+
+    title = _("Content's internal links")
+
+
+@adapter_config(name='name', context=(Interface, IPyAMSLayer, SequentialIdTargetReverseLinkTable), provides=IColumn)
+class ReverseLinkNameColumn(NameColumn):
+    """Reverse link name column"""
+
+    _header = _("Title")
+
+
+@adapter_config(context=(IWfSharedContent, IPyAMSLayer, SequentialIdTargetReverseLinkTable), provides=IValues)
+class SequentialIdTargetReverseLinkValues(ContextRequestViewAdapter):
+    """Sequential ID target reverse links values"""
+
+    @property
+    def values(self):
+
+        def get_item(result):
+            parent = get_parent(result, IWfSharedContent)
+            if parent is not None:
+                return IWorkflowVersions(parent).get_last_versions(count=1)[0]
+            parent = get_parent(result, IPortalTemplate)
+            if parent is None:
+                parent = get_parent(result, ISiteContainer)
+            if parent is None:
+                parent = self.request.root
+            return parent
+
+        catalog = get_utility(ICatalog)
+        oid = ISequentialIdInfo(self.context).hex_oid
+        params = Or(Eq(catalog['link_reference'], oid),
+                    Eq(catalog['link_references'], oid))
+        return unique_iter(map(get_item,
+                               CatalogResultSet(CatalogQuery(catalog).query(params,
+                                                                            sort_index='modified_date'))))
+
+
+@pagelet_config(name='reverse-links.html', context=IWfSharedContent, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
+@implementer(IInnerPage)
+class SequentialIdTargetReverseLinkView(AdminView, ContainerView):
+    """Sequential ID target reverse links view"""
+
+    table_class = SequentialIdTargetReverseLinkTable