Query content type on all dashboards
authorThierry Florac <thierry.florac@onf.fr>
Wed, 27 Jun 2018 15:15:38 +0200
changeset 759 780d6776a857
parent 758 6aca2a06cbe3
child 760 ff178ccbce6f
Query content type on all dashboards
src/pyams_content/root/zmi/__init__.py
src/pyams_content/shared/common/zmi/dashboard.py
--- a/src/pyams_content/root/zmi/__init__.py	Wed Jun 27 15:15:13 2018 +0200
+++ b/src/pyams_content/root/zmi/__init__.py	Wed Jun 27 15:15:38 2018 +0200
@@ -172,6 +172,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = Eq(catalog['parents'], intids.register(tool)) & \
+                    Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                     Any(catalog['workflow_state'], workflow.waiting_states)
             params = params | query if params else query
         return filter(self.check_access,
@@ -218,6 +219,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = Eq(catalog['parents'], intids.register(tool)) & \
+                    Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                     Any(catalog['workflow_state'], workflow.waiting_states) & \
                     Eq(catalog['workflow_principal'], self.request.principal.id)
             params = params | query if params else query
@@ -379,6 +381,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = And(Eq(catalog['parents'], intids.register(tool)),
+                        Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
                         Eq(catalog['workflow_state'], workflow.initial_state))
@@ -440,6 +443,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = And(Eq(catalog['parents'], intids.register(tool)),
+                        Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
                         Any(catalog['workflow_state'], workflow.waiting_states))
@@ -501,6 +505,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = And(Eq(catalog['parents'], intids.register(tool)),
+                        Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
                         Any(catalog['workflow_state'], workflow.published_states))
@@ -562,6 +567,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = And(Eq(catalog['parents'], intids.register(tool)),
+                        Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
                         Any(catalog['workflow_state'], workflow.retired_states))
@@ -625,6 +631,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = And(Eq(catalog['parents'], intids.register(tool)),
+                        Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                         Or(Eq(catalog['role:owner'], principal_id),
                            Eq(catalog['role:contributor'], principal_id)),
                         Any(catalog['workflow_state'], workflow.archived_states))
@@ -714,6 +721,7 @@
         for tool in get_all_utilities_registered_for(IBaseSharedTool):
             workflow = IWorkflow(tool)
             query = And(Eq(catalog['parents'], intids.register(tool)),
+                        Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                         Any(catalog['workflow_state'], workflow.published_states))
             params = params | query if params else query
         return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
--- a/src/pyams_content/shared/common/zmi/dashboard.py	Wed Jun 27 15:15:13 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/dashboard.py	Wed Jun 27 15:15:38 2018 +0200
@@ -340,6 +340,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = Eq(catalog['parents'], intids.register(self.context)) & \
+                 Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                  Any(catalog['workflow_state'], workflow.waiting_states)
         return filter(self.check_access,
                       unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
@@ -383,6 +384,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = Eq(catalog['parents'], intids.register(self.context)) & \
+                 Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                  Any(catalog['workflow_state'], workflow.waiting_states) & \
                  Eq(catalog['workflow_principal'], self.request.principal.id)
         return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
@@ -576,6 +578,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = And(Eq(catalog['parents'], intids.register(self.context)),
+                     Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                      Or(Eq(catalog['role:owner'], self.request.principal.id),
                         Eq(catalog['role:contributor'], self.request.principal.id)),
                      Eq(catalog['workflow_state'], workflow.initial_state))
@@ -638,6 +641,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = And(Eq(catalog['parents'], intids.register(self.context)),
+                     Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                      Or(Eq(catalog['role:owner'], self.request.principal.id),
                         Eq(catalog['role:contributor'], self.request.principal.id)),
                      Any(catalog['workflow_state'], workflow.waiting_states))
@@ -700,6 +704,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = And(Eq(catalog['parents'], intids.register(self.context)),
+                     Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                      Or(Eq(catalog['role:owner'], self.request.principal.id),
                         Eq(catalog['role:contributor'], self.request.principal.id)),
                      Any(catalog['workflow_state'], workflow.published_states))
@@ -762,6 +767,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = And(Eq(catalog['parents'], intids.register(self.context)),
+                     Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                      Or(Eq(catalog['role:owner'], self.request.principal.id),
                         Eq(catalog['role:contributor'], self.request.principal.id)),
                      Any(catalog['workflow_state'], workflow.retired_states))
@@ -826,6 +832,7 @@
         principal_id = self.request.principal.id
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = And(Eq(catalog['parents'], intids.register(self.context)),
+                     Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                      Or(Eq(catalog['role:owner'], principal_id),
                         Eq(catalog['role:contributor'], principal_id)),
                      Any(catalog['workflow_state'], workflow.archived_states))
@@ -916,6 +923,7 @@
         catalog = get_utility(ICatalog)
         workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow)
         params = And(Eq(catalog['parents'], intids.register(self.context)),
+                     Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
                      Any(catalog['workflow_state'], workflow.published_states))
         return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
                                                                    limit=50,