19 |
19 |
20 * entity types defining workflow (Workflow, State, Transition...) |
20 * entity types defining workflow (Workflow, State, Transition...) |
21 * workflow history (TrInfo) |
21 * workflow history (TrInfo) |
22 * adapter for workflowable entities (IWorkflowableAdapter) |
22 * adapter for workflowable entities (IWorkflowableAdapter) |
23 """ |
23 """ |
|
24 from __future__ import print_function |
24 |
25 |
25 __docformat__ = "restructuredtext en" |
26 __docformat__ = "restructuredtext en" |
26 |
27 |
27 |
28 |
28 from logilab.common.decorators import cached, clear_cache |
29 from logilab.common.decorators import cached, clear_cache |
222 groups = frozenset(g.name for g in self.require_group) |
223 groups = frozenset(g.name for g in self.require_group) |
223 if groups: |
224 if groups: |
224 matches = user.matching_groups(groups) |
225 matches = user.matching_groups(groups) |
225 if matches: |
226 if matches: |
226 if DBG: |
227 if DBG: |
227 print 'may_be_fired: %r may fire: user matches %s' % (self.name, groups) |
228 print('may_be_fired: %r may fire: user matches %s' % (self.name, groups)) |
228 return matches |
229 return matches |
229 if 'owners' in groups and user.owns(eid): |
230 if 'owners' in groups and user.owns(eid): |
230 if DBG: |
231 if DBG: |
231 print 'may_be_fired: %r may fire: user is owner' % self.name |
232 print('may_be_fired: %r may fire: user is owner' % self.name) |
232 return True |
233 return True |
233 # check one of the rql expression conditions matches if any |
234 # check one of the rql expression conditions matches if any |
234 if self.condition: |
235 if self.condition: |
235 if DBG: |
236 if DBG: |
236 print ('my_be_fired: %r: %s' % |
237 print('my_be_fired: %r: %s' % |
237 (self.name, [(rqlexpr.expression, |
238 (self.name, [(rqlexpr.expression, |
238 rqlexpr.check_expression(self._cw, eid)) |
239 rqlexpr.check_expression(self._cw, eid)) |
239 for rqlexpr in self.condition])) |
240 for rqlexpr in self.condition])) |
240 for rqlexpr in self.condition: |
241 for rqlexpr in self.condition: |
241 if rqlexpr.check_expression(self._cw, eid): |
242 if rqlexpr.check_expression(self._cw, eid): |
242 return True |
243 return True |
243 if self.condition or groups: |
244 if self.condition or groups: |
244 return False |
245 return False |