Use adapters to get notifications contexts
authorThierry Florac <thierry.florac@onf.fr>
Tue, 12 Sep 2017 11:13:34 +0200
changeset 22 cba9ce0e9ee2
parent 21 16f44247bcbf
child 23 4b15a158f85f
Use adapters to get notifications contexts
src/pyams_notify/views/context.py
--- a/src/pyams_notify/views/context.py	Mon Sep 11 15:06:26 2017 +0200
+++ b/src/pyams_notify/views/context.py	Tue Sep 12 11:13:34 2017 +0200
@@ -10,15 +10,16 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-
 __docformat__ = 'restructuredtext'
 
 
 # import standard library
 
 # import interfaces
+from pyams_notify.interfaces import INotificationHandler
 
 # import packages
+from pyams_notify.event import Notification
 from pyramid.view import view_config
 
 
@@ -26,7 +27,12 @@
 def NotificationsContextView(request):
     """Get context for notifications"""
     principal = request.principal
+    notification = Notification(request,
+                                action='none',
+                                category='notifications.query',
+                                message='')
+    adapters = [name for name, adapter in request.registry.getAdapters((notification, ), INotificationHandler)]
     return {'principal': {'id': principal.id,
                           'title': principal.title,
                           'principals': tuple(request.effective_principals)},
-            'context': {'*': ['user.login', 'content.workflow']}}
+            'context': {'*': adapters}}