equal
deleted
inserted
replaced
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
|
12 from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent |
12 |
13 |
13 __docformat__ = 'restructuredtext' |
14 __docformat__ = 'restructuredtext' |
14 |
15 |
15 |
16 |
16 # import standard library |
17 # import standard library |
63 content_type = VIEW_CONTENT_TYPE |
64 content_type = VIEW_CONTENT_TYPE |
64 content_name = VIEW_CONTENT_NAME |
65 content_name = VIEW_CONTENT_NAME |
65 |
66 |
66 select_context_type = FieldProperty(IWfView['select_context_type']) |
67 select_context_type = FieldProperty(IWfView['select_context_type']) |
67 selected_content_types = FieldProperty(IWfView['selected_content_types']) |
68 selected_content_types = FieldProperty(IWfView['selected_content_types']) |
|
69 select_context_datatype = FieldProperty(IWfView['select_context_datatype']) |
|
70 selected_datatypes = FieldProperty(IWfView['selected_datatypes']) |
68 order_by = FieldProperty(IWfView['order_by']) |
71 order_by = FieldProperty(IWfView['order_by']) |
69 reversed_order = FieldProperty(IWfView['reversed_order']) |
72 reversed_order = FieldProperty(IWfView['reversed_order']) |
70 limit = FieldProperty(IWfView['limit']) |
73 limit = FieldProperty(IWfView['limit']) |
71 |
74 |
72 @property |
75 @property |
86 if self.select_context_type: |
89 if self.select_context_type: |
87 content_types.add(context.content_type) |
90 content_types.add(context.content_type) |
88 if self.selected_content_types: |
91 if self.selected_content_types: |
89 content_types |= set(self.selected_content_types) |
92 content_types |= set(self.selected_content_types) |
90 return list(content_types) |
93 return list(content_types) |
|
94 |
|
95 def get_data_types(self, context): |
|
96 data_types = set() |
|
97 if self.select_context_datatype: |
|
98 content = IWfTypedSharedContent(context, None) |
|
99 if content is not None: |
|
100 data_types.add(content.data_type) |
|
101 if self.selected_datatypes: |
|
102 data_types |= set(self.selected_datatypes) |
|
103 return list(data_types) |
91 |
104 |
92 def get_results(self, context, sort_index=None, reverse=None, limit=None, ignore_cache=False): |
105 def get_results(self, context, sort_index=None, reverse=None, limit=None, ignore_cache=False): |
93 results = _MARKER |
106 results = _MARKER |
94 if not ignore_cache: |
107 if not ignore_cache: |
95 # check for cache |
108 # check for cache |
151 params &= Gt(catalog['push_end_date'], now) |
164 params &= Gt(catalog['push_end_date'], now) |
152 # check content types |
165 # check content types |
153 content_types = view.get_content_types(context) |
166 content_types = view.get_content_types(context) |
154 if content_types: |
167 if content_types: |
155 params &= Any(catalog['content_type'], content_types) |
168 params &= Any(catalog['content_type'], content_types) |
|
169 # check data types |
|
170 data_types = view.get_data_types(context) |
|
171 if data_types: |
|
172 params &= Any(catalog['data_type'], data_types) |
156 # check workflow states |
173 # check workflow states |
157 wf_params = None |
174 wf_params = None |
158 for workflow in registry.getAllUtilitiesRegisteredFor(IWorkflow): |
175 for workflow in registry.getAllUtilitiesRegisteredFor(IWorkflow): |
159 wf_params = or_(wf_params, Any(catalog['workflow_state'], workflow.published_states)) |
176 wf_params = or_(wf_params, Any(catalog['workflow_state'], workflow.published_states)) |
160 params &= wf_params |
177 params &= wf_params |