Updated version check
authorThierry Florac <thierry.florac@onf.fr>
Fri, 23 Nov 2018 13:23:22 +0100
changeset 1112 6f9d0e77f4ce
parent 1111 e937fd3c40c2
child 1113 5f026f7b6ada
Updated version check
src/pyams_content/root/zmi/search.py
--- a/src/pyams_content/root/zmi/search.py	Fri Nov 23 13:23:09 2018 +0100
+++ b/src/pyams_content/root/zmi/search.py	Fri Nov 23 13:23:22 2018 +0100
@@ -12,36 +12,33 @@
 
 __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.interface import implementer
+from zope.intid import IIntIds
+from zope.schema import Choice, Datetime, List
 
-# import interfaces
-from hypatia.interfaces import ICatalog
+from pyams_catalog.query import CatalogResultSet
 from pyams_content.component.theme.interfaces import ITagsManager
 from pyams_content.profile.interfaces import IAdminProfile
 from pyams_content.root import ISiteRoot
+from pyams_content.shared.common import CONTENT_TYPES
 from pyams_content.shared.common.interfaces import CONTENT_TYPES_VOCABULARY
 from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable
 from pyams_content.zmi.interfaces import IAllContentsMenu
-from pyams_form.search import ISearchFields, SearchForm, SearchView, SearchResultsView
+from pyams_form.search import ISearchFields, SearchForm, SearchResultsView, SearchView
 from pyams_i18n.interfaces import INegotiator
-from pyams_sequence.interfaces import ISequentialIntIds
-from pyams_skin.interfaces import IInnerPage, IContentSearch, IPageHeader
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_workflow.interfaces import IWorkflowVersions
-from pyams_zmi.layer import IAdminLayer
-from z3c.table.interfaces import IValues
-from zope.intid import IIntIds
-
-# import packages
-from hypatia.catalog import CatalogQuery
-from hypatia.query import Eq, Any, Contains, Ge, Le
-from pyams_catalog.query import CatalogResultSet
-from pyams_content.shared.common import CONTENT_TYPES
 from pyams_pagelet.interfaces import PageletCreatedEvent
 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
@@ -49,16 +46,14 @@
 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.url import absolute_url
 from pyams_viewlet.viewlet import viewlet_config
+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, List
 
 from pyams_content import _
 
@@ -134,7 +129,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))))
@@ -247,7 +242,7 @@
         if data.get('tags'):
             tags = [intids.register(term) for term in data['tags']]
             params &= Any(catalog['tags'], tags)
-        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))))