Added workflow states vocabulary
authorThierry Florac <tflorac@ulthar.net>
Sat, 27 Jan 2018 02:21:44 +0100
changeset 347 c37df4232749
parent 346 9e4ae14bdf3a
child 348 d73905f6a2eb
Added workflow states vocabulary
src/pyams_content/shared/common/zmi/search.py
--- a/src/pyams_content/shared/common/zmi/search.py	Sat Jan 27 00:50:34 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/search.py	Sat Jan 27 02:21:44 2018 +0100
@@ -37,7 +37,6 @@
 from hypatia.catalog import CatalogQuery
 from hypatia.query import Eq, Contains, Ge, Le, Any
 from pyams_content.shared.common import CONTENT_TYPES
-from pyams_content.workflow import STATES_VOCABULARY
 from pyams_catalog.query import CatalogResultSet
 from pyams_form.search import SearchView, SearchForm, SearchResultsView, ISearchFields
 from pyams_pagelet.pagelet import pagelet_config
@@ -50,7 +49,9 @@
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 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_zmi.view import AdminView
 from pyramid.view import view_config
@@ -134,6 +135,15 @@
 # Advanced search views
 #
 
+@vocabulary_config(name='PyAMS workflow states')
+def WorkflowStatesVocabulary(context):
+    """Workflow states vocabulary"""
+    target = get_parent(context, IBaseSharedTool)
+    if target is not None:
+        workflow = IWorkflow(target)
+        return workflow.states
+
+
 @viewlet_config(name='advanced-search.menu', context=IBaseSharedTool, layer=IAdminLayer,
                 manager=IAllContentsMenu, permission=VIEW_SYSTEM_PERMISSION, weight=90)
 class SharedToolAdvancedSearchMenu(MenuItem):
@@ -151,7 +161,7 @@
                       required=False)
 
     status = Choice(title=_("Status"),
-                    vocabulary=STATES_VOCABULARY,
+                    vocabulary='PyAMS workflow states',
                     required=False)
 
     created_after = Datetime(title=_("Created after..."),