# HG changeset patch # User Thierry Florac # Date 1535469899 -7200 # Node ID 69b028b6eecb4625e311cb932f9275b4896448b6 # Parent 2d346aeb66d6ddf0ee043de7b0e2f340b7b9aaab Updated advanced search engine to search over tags, themes and collections diff -r 2d346aeb66d6 -r 69b028b6eecb src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo Binary file src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo has changed diff -r 2d346aeb66d6 -r 69b028b6eecb src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po --- a/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po Tue Aug 28 16:19:33 2018 +0200 +++ b/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po Tue Aug 28 17:24:59 2018 +0200 @@ -4953,7 +4953,7 @@ #: src/pyams_content/features/checker/zmi/__init__.py:82 msgid "No checker available. This content is clean!" -msgstr "Pas de vérificateur disponible. Ce contenu est propre !" +msgstr "Pas de vérificateur disponible pour ce contenu." #: src/pyams_content/features/checker/zmi/__init__.py:78 #, python-format diff -r 2d346aeb66d6 -r 69b028b6eecb src/pyams_content/root/zmi/search.py --- a/src/pyams_content/root/zmi/search.py Tue Aug 28 16:19:33 2018 +0200 +++ b/src/pyams_content/root/zmi/search.py Tue Aug 28 17:24:59 2018 +0200 @@ -17,8 +17,10 @@ # import interfaces from hypatia.interfaces import ICatalog +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.interfaces import CONTENT_TYPES_VOCABULARY from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable from pyams_content.skin.zmi.interfaces import IAllContentsMenu from pyams_form.search import ISearchFields, SearchForm, SearchView, SearchResultsView @@ -45,6 +47,8 @@ from pyams_skin.table import BaseTable from pyams_skin.viewlet.menu import MenuItem 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.list import unique from pyams_utils.registry import get_utility @@ -154,7 +158,7 @@ """Site root advanced search fields""" content_type = List(title=_("Content types"), - value_type=Choice(vocabulary='PyAMS content types'), + value_type=Choice(vocabulary=CONTENT_TYPES_VOCABULARY), required=False) owner = Principal(title=_("Owner"), @@ -172,6 +176,9 @@ modified_before = Datetime(title=_("Modified before..."), required=False) + tags = ThesaurusTermsListField(title=_("Tags"), + required=False) + @template_config(template='templates/advanced-search.pt', layer=IPyAMSLayer) @implementer(IInnerPage) @@ -186,8 +193,17 @@ apply_skin(self.request, 'PyAMS admin skin') fields = field.Fields(ISiteRootAdvancedSearchFields) + fields['tags'].widgetFactory = ThesaurusTermsTreeFieldWidget ajax_handler = 'advanced-search-results.html' + def updateWidgets(self, prefix=None): + super(SiteRootAdvancedSearchForm, self).updateWidgets(prefix) + if 'tags' in self.widgets: + widget = self.widgets['tags'] + manager = ITagsManager(self.request.root) + widget.thesaurus_name = manager.thesaurus_name + widget.extract_name = manager.extract_name + @adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootAdvancedSearchForm), provides=IContentSearch) class SiteRootAdvancedSearchFormSearchAdapter(ContextRequestViewAdapter): @@ -228,6 +244,9 @@ params &= Ge(catalog['modified_date'], data['modified_after']) if data.get('modified_before'): params &= Le(catalog['modified_date'], data['modified_before']) + 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], CatalogResultSet(CatalogQuery(catalog).query(params, sort_index='modified_date', diff -r 2d346aeb66d6 -r 69b028b6eecb src/pyams_content/root/zmi/templates/advanced-search.pt --- a/src/pyams_content/root/zmi/templates/advanced-search.pt Tue Aug 28 16:19:33 2018 +0200 +++ b/src/pyams_content/root/zmi/templates/advanced-search.pt Tue Aug 28 17:24:59 2018 +0200 @@ -102,8 +102,10 @@ + +
-