Added event object as context in workflow notifications
authorThierry Florac <thierry.florac@onf.fr>
Fri, 08 Jul 2016 15:37:51 +0200
changeset 5 f7693c6641a9
parent 4 9698e6853781
child 6 9f612bc66626
Added event object as context in workflow notifications
src/pyams_notify/handlers/workflow.py
--- a/src/pyams_notify/handlers/workflow.py	Fri Jul 08 15:37:20 2016 +0200
+++ b/src/pyams_notify/handlers/workflow.py	Fri Jul 08 15:37:51 2016 +0200
@@ -41,6 +41,7 @@
         return
     translate = request.localizer.translate
     notification = Notification(request=request,
+                                context=event.object,
                                 action='notify',
                                 category='content.workflow',
                                 message=translate(transition.user_data['notify_message']).format(
@@ -64,6 +65,7 @@
                 protection = IProtectedObject(context, None)
                 if protection is not None:
                     principals |= protection.get_principals(role_id)
-        if self.context.source['id'] in principals:
-            principals.remove(self.context.source['id'])
+        source_id = self.context.source['id']
+        if source_id in principals:
+            principals.remove(source_id)
         return {'principals': tuple(principals)}