Added interface for internal links references list
authorThierry Florac <thierry.florac@onf.fr>
Tue, 27 Jun 2017 11:45:35 +0200
changeset 88 758d0cb86132
parent 87 f382a0fb2375
child 89 4e593a05b02d
Added interface for internal links references list
src/pyams_content/component/links/interfaces/__init__.py
src/pyams_content/component/links/zmi/reverse.py
--- a/src/pyams_content/component/links/interfaces/__init__.py	Tue Jun 20 16:40:56 2017 +0200
+++ b/src/pyams_content/component/links/interfaces/__init__.py	Tue Jun 27 11:45:35 2017 +0200
@@ -22,7 +22,7 @@
 
 # import packages
 from pyams_i18n.schema import I18nTextLineField, I18nTextField
-from pyams_sequence.schema import InternalReference
+from pyams_sequence.schema import InternalReference, InternalReferencesList
 from pyams_utils.schema import PersistentList
 from zope.container.constraints import containers, contains
 from zope.interface import Interface
@@ -114,3 +114,11 @@
 
 class ILinkLinksContainerTarget(Interface):
     """Links links container marker interface"""
+
+
+class IInternalReferencesList(Interface):
+    """Internal references list"""
+
+    references = InternalReferencesList(title=_("Internal references"),
+                                        description=_("List of internal references"),
+                                        required=False)
--- a/src/pyams_content/component/links/zmi/reverse.py	Tue Jun 20 16:40:56 2017 +0200
+++ b/src/pyams_content/component/links/zmi/reverse.py	Tue Jun 27 11:45:35 2017 +0200
@@ -30,7 +30,7 @@
 
 # import packages
 from hypatia.catalog import CatalogQuery
-from hypatia.query import Eq
+from hypatia.query import Eq, Or, Any
 from pyams_catalog.query import CatalogResultSet
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.container import ContainerView
@@ -71,7 +71,9 @@
     @property
     def values(self):
         catalog = get_utility(ICatalog)
-        params = Eq(catalog['link_reference'], ISequentialIdInfo(self.context).hex_oid)
+        oid = ISequentialIdInfo(self.context).hex_oid
+        params = Or(Eq(catalog['link_reference'], oid),
+                    Eq(catalog['link_references'], oid))
         return unique(map(lambda x: IWorkflowVersions(get_parent(x, IWfSharedContent)).get_last_versions(count=1)[0],
                           CatalogResultSet(CatalogQuery(catalog).query(params,
                                                                        sort_index='modified_date'))))