--- a/src/pyams_content/shared/common/zmi/search.py Fri Nov 23 12:12:52 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/search.py Fri Nov 23 13:23:09 2018 +0100
@@ -12,37 +12,34 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
+from hypatia.catalog import CatalogQuery
+from hypatia.interfaces import ICatalog
+from hypatia.query import Any, Contains, Eq, Ge, Le
+from pyramid.view import view_config
+from z3c.form import field
+from z3c.table.interfaces import IValues
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.interface import implementer
+from zope.intid.interfaces import IIntIds
+from zope.schema import Choice, Datetime
-# import interfaces
-from hypatia.interfaces import ICatalog
-from pyams_content.component.theme.interfaces import ITagsManager, IThemesManagerTarget, IThemesManager, \
- ICollectionsManagerTarget, ICollectionsManager
+from pyams_catalog.query import CatalogResultSet
+from pyams_content.component.theme.interfaces import ICollectionsManager, ICollectionsManagerTarget, ITagsManager, \
+ IThemesManager, IThemesManagerTarget
from pyams_content.profile.interfaces import IAdminProfile
+from pyams_content.shared.common import CONTENT_TYPES
from pyams_content.shared.common.interfaces import IBaseSharedTool
from pyams_content.shared.common.interfaces.zmi import ISharedToolDashboardTable
from pyams_content.zmi.interfaces import IAllContentsMenu
+from pyams_form.search import ISearchFields, SearchForm, SearchResultsView, SearchView
from pyams_i18n.interfaces import INegotiator
from pyams_pagelet.interfaces import PageletCreatedEvent
-from pyams_sequence.interfaces import ISequentialIntIds
-from pyams_skin.interfaces import IPageHeader, IContentSearch, IInnerPage
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_workflow.interfaces import IWorkflowVersions, IWorkflow
-from pyams_zmi.layer import IAdminLayer
-from z3c.table.interfaces import IValues
-from zope.dublincore.interfaces import IZopeDublinCore
-from zope.intid.interfaces import IIntIds
-
-# import packages
-from hypatia.catalog import CatalogQuery
-from hypatia.query import Eq, Contains, Ge, Le, Any
-from pyams_content.shared.common import CONTENT_TYPES
-from pyams_catalog.query import CatalogResultSet
-from pyams_form.search import SearchView, SearchForm, SearchResultsView, ISearchFields
from pyams_pagelet.pagelet import pagelet_config
from pyams_security.schema import Principal
+from pyams_sequence.interfaces import ISequentialIntIds
+from pyams_sequence.reference import get_last_version
+from pyams_skin.interfaces import IContentSearch, IInnerPage, IPageHeader
+from pyams_skin.layer import IPyAMSLayer
from pyams_skin.page import DefaultPageHeaderAdapter
from pyams_skin.skin import apply_skin
from pyams_skin.table import BaseTable
@@ -50,18 +47,17 @@
from pyams_template.template import template_config
from pyams_thesaurus.schema import ThesaurusTermsListField
from pyams_thesaurus.zmi.widget import ThesaurusTermsTreeFieldWidget
-from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
+from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
from pyams_utils.list import unique
from pyams_utils.registry import get_utility
from pyams_utils.traversing import get_parent
from pyams_utils.url import absolute_url
from pyams_utils.vocabulary import vocabulary_config
from pyams_viewlet.viewlet import viewlet_config
+from pyams_workflow.interfaces import IWorkflow, IWorkflowVersions
+from pyams_zmi.layer import IAdminLayer
from pyams_zmi.view import AdminView
-from pyramid.view import view_config
-from z3c.form import field
-from zope.interface import implementer
-from zope.schema import Datetime, Choice
from pyams_content import _
@@ -135,7 +131,7 @@
if index.check_query(query):
query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
params &= query_params
- return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
+ return unique(map(get_last_version,
CatalogResultSet(CatalogQuery(catalog).query(params,
sort_index='modified_date',
reverse=True))))
@@ -299,7 +295,7 @@
sort_index='modified_date',
reverse=True))))
else:
- return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
+ return unique(map(get_last_version,
CatalogResultSet(CatalogQuery(catalog).query(params,
sort_index='modified_date',
reverse=True))))