equal
deleted
inserted
replaced
34 rset=rset, row=0, col=0) |
34 rset=rset, row=0, col=0) |
35 |
35 |
36 |
36 |
37 class StatusChangeHook(NotificationHook): |
37 class StatusChangeHook(NotificationHook): |
38 """notify when a workflowable entity has its state modified""" |
38 """notify when a workflowable entity has its state modified""" |
39 __id__ = 'notifystatuschange' |
39 __regid__ = 'notifystatuschange' |
40 __select__ = NotificationHook.__select__ & entity_implements('TrInfo') |
40 __select__ = NotificationHook.__select__ & entity_implements('TrInfo') |
41 events = ('after_add_entity',) |
41 events = ('after_add_entity',) |
42 |
42 |
43 def __call__(self): |
43 def __call__(self): |
44 entity = self.entity |
44 entity = self.entity |
57 'comment': comment, 'previous_state': entity.previous_state.name, |
57 'comment': comment, 'previous_state': entity.previous_state.name, |
58 'current_state': entity.new_state.name}) |
58 'current_state': entity.new_state.name}) |
59 |
59 |
60 |
60 |
61 class RelationChangeHook(NotificationHook): |
61 class RelationChangeHook(NotificationHook): |
62 __id__ = 'notifyrelationchange' |
62 __regid__ = 'notifyrelationchange' |
63 events = ('before_add_relation', 'after_add_relation', |
63 events = ('before_add_relation', 'after_add_relation', |
64 'before_delete_relation', 'after_delete_relation') |
64 'before_delete_relation', 'after_delete_relation') |
65 |
65 |
66 def __call__(self): |
66 def __call__(self): |
67 """if a notification view is defined for the event, send notification |
67 """if a notification view is defined for the event, send notification |
77 |
77 |
78 class EntityChangeHook(NotificationHook): |
78 class EntityChangeHook(NotificationHook): |
79 """if a notification view is defined for the event, send notification |
79 """if a notification view is defined for the event, send notification |
80 email defined by the view |
80 email defined by the view |
81 """ |
81 """ |
82 __id__ = 'notifyentitychange' |
82 __regid__ = 'notifyentitychange' |
83 events = ('after_add_entity', 'after_update_entity') |
83 events = ('after_add_entity', 'after_update_entity') |
84 |
84 |
85 def __call__(self): |
85 def __call__(self): |
86 rset = self.entity.as_rset() |
86 rset = self.entity.as_rset() |
87 view = self.select_view('notif_%s' % self.event, rset=rset, row=0) |
87 view = self.select_view('notif_%s' % self.event, rset=rset, row=0) |
91 |
91 |
92 |
92 |
93 # supervising ################################################################## |
93 # supervising ################################################################## |
94 |
94 |
95 class SomethingChangedHook(NotificationHook): |
95 class SomethingChangedHook(NotificationHook): |
96 __id__ = 'supervising' |
96 __regid__ = 'supervising' |
97 events = ('before_add_relation', 'before_delete_relation', |
97 events = ('before_add_relation', 'before_delete_relation', |
98 'after_add_entity', 'before_update_entity') |
98 'after_add_entity', 'before_update_entity') |
99 |
99 |
100 def __call__(self): |
100 def __call__(self): |
101 # XXX use proper selectors |
101 # XXX use proper selectors |
122 (event, self)) |
122 (event, self)) |
123 return True |
123 return True |
124 |
124 |
125 |
125 |
126 class EntityDeleteHook(SomethingChangedHook): |
126 class EntityDeleteHook(SomethingChangedHook): |
127 __id__ = 'supervisingentitydel' |
127 __regid__ = 'supervisingentitydel' |
128 events = ('before_delete_entity',) |
128 events = ('before_delete_entity',) |
129 |
129 |
130 def _call(self): |
130 def _call(self): |
131 try: |
131 try: |
132 title = self.entity.dc_title() |
132 title = self.entity.dc_title() |