--- a/src/pyams_content/shared/common/zmi/search.py Wed Jul 15 18:02:59 2020 +0200
+++ b/src/pyams_content/shared/common/zmi/search.py Thu Jul 16 17:39:51 2020 +0200
@@ -23,7 +23,7 @@
from pyams_catalog.query import CatalogResultSet
from pyams_content.component.theme.interfaces import ICollectionsManager, \
- ICollectionsManagerTarget, ITagsManager, IThemesManager, IThemesManagerTarget
+ 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, \
@@ -101,13 +101,16 @@
def data_attributes(self):
attributes = super(SharedToolQuickSearchResults, self).data_attributes
attributes['table'] = {
- 'data-ams-datatable-sorting': '{0},{1}'.format(len(self.columns) - 1, self.dt_sort_order),
- 'data-ams-datatable-display-length': IAdminProfile(self.request.principal).table_page_length
+ 'data-ams-datatable-sorting':
+ '{0},{1}'.format(len(self.columns) - 1, self.dt_sort_order),
+ 'data-ams-datatable-display-length':
+ IAdminProfile(self.request.principal).table_page_length
}
return attributes
-@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolQuickSearchResults), provides=IValues)
+@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolQuickSearchResults),
+ provides=IValues)
class SharedToolQuickSearchValues(ContextRequestViewAdapter):
"""Shared tool quick search results view values adapter"""
@@ -126,19 +129,20 @@
Any(catalog['content_type'], CONTENT_TYPES.keys())
query_params = Eq(catalog['oid'], sequence.get_full_oid(query))
negotiator = get_utility(INegotiator)
- for lang in {self.request.registry.settings.get('pyramid.default_locale_name', 'en'),
+ for lang in {self.request.registry.settings.get('pyramid.default_locale_name',
+ 'en'),
self.request.locale_name,
negotiator.server_language} | negotiator.offered_languages:
index_name = 'title:{0}'.format(lang)
if index_name in catalog:
index = catalog[index_name]
if index.check_query(query):
- query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
+ query_params |= Contains(index,
+ ' and '.join((w+'*' for w in query.split())))
params &= query_params
return unique(map(get_last_version,
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ CatalogResultSet(CatalogQuery(catalog).query(
+ params, sort_index='modified_date', reverse=True))))
else:
return ()
@@ -250,7 +254,8 @@
widget.extract_name = manager.extract_name
-@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolAdvancedSearchForm), provides=IContentSearch)
+@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolAdvancedSearchForm),
+ provides=IContentSearch)
class SharedToolAdvancedSearchFormSearchAdapter(ContextRequestViewAdapter):
"""Shared tool adavanced search form search adapter"""
@@ -267,14 +272,16 @@
else:
query_params = Eq(catalog['oid'], sequence.get_full_oid(query))
negotiator = get_utility(INegotiator)
- for lang in {self.request.registry.settings.get('pyramid.default_locale_name', 'en'),
+ for lang in {self.request.registry.settings.get('pyramid.default_locale_name',
+ 'en'),
self.request.locale_name,
negotiator.server_language} | negotiator.offered_languages:
index_name = 'title:{0}'.format(lang)
if index_name in catalog:
index = catalog[index_name]
if index.check_query(query):
- query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
+ query_params |= Contains(index,
+ ' and '.join((w+'*' for w in query.split())))
params &= query_params
if data.get('owner'):
params &= Eq(catalog['role:owner'], data['owner'])
@@ -302,14 +309,12 @@
if data.get('status'):
return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(data['status']),
key=lambda y: IZopeDublinCore(y).modified)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ CatalogResultSet(CatalogQuery(catalog).query(
+ params, sort_index='modified_date', reverse=True))))
else:
return unique(map(get_last_version,
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ CatalogResultSet(CatalogQuery(catalog).query(
+ params, sort_index='modified_date', reverse=True))))
@pagelet_config(name='advanced-search.html', context=IBaseSharedTool, layer=IPyAMSLayer,
@@ -320,7 +325,8 @@
search_form_factory = SharedToolAdvancedSearchForm
-@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolAdvancedSearchView), provides=IPageHeader)
+@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolAdvancedSearchView),
+ provides=IPageHeader)
class SharedToolAdvancedSearchHeaderAdapter(DefaultPageHeaderAdapter):
"""Shared tool advanced search header adapter"""
@@ -330,8 +336,8 @@
icon_class = 'fa fa-fw fa-search'
-@view_config(name='advanced-search-results.html', context=IBaseSharedTool, request_type=IPyAMSLayer,
- permission=VIEW_SYSTEM_PERMISSION)
+@view_config(name='advanced-search-results.html', context=IBaseSharedTool,
+ request_type=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@implementer(ISharedToolDashboardTable)
class SharedToolAdvancedSearchResultsView(AdminView, SearchResultsView):
"""Shared tool advanced search results view"""
@@ -350,13 +356,16 @@
def data_attributes(self):
attributes = super(SharedToolAdvancedSearchResultsView, self).data_attributes
attributes['table'] = {
- 'data-ams-datatable-sorting': "{0},{1}".format(len(self.columns) - 1, self.dt_sort_order),
- 'data-ams-datatable-display-length': IAdminProfile(self.request.principal).table_page_length
+ 'data-ams-datatable-sorting':
+ "{0},{1}".format(len(self.columns) - 1, self.dt_sort_order),
+ 'data-ams-datatable-display-length':
+ IAdminProfile(self.request.principal).table_page_length
}
return attributes
-@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolAdvancedSearchResultsView), provides=IValues)
+@adapter_config(context=(IBaseSharedTool, IPyAMSLayer, SharedToolAdvancedSearchResultsView),
+ provides=IValues)
class SearchResultsViewValuesAdapter(ContextRequestViewAdapter):
"""Search results view values adapter"""