Use constants for roles
authorThierry Florac <thierry.florac@onf.fr>
Tue, 26 Jun 2018 14:59:33 +0200
changeset 35 b38715db69e1
parent 34 a9e5a6bd8ca2
child 36 4b8fa12fe88b
Use constants for roles
src/pyams_notify/handlers/login.py
--- a/src/pyams_notify/handlers/login.py	Tue Mar 20 17:46:24 2018 +0100
+++ b/src/pyams_notify/handlers/login.py	Tue Jun 26 14:59:33 2018 +0200
@@ -16,8 +16,9 @@
 # import standard library
 
 # import interfaces
+from pyams_content.interfaces import WEBMASTER_ROLE
 from pyams_notify.interfaces import INotification, INotificationHandler
-from pyams_security.interfaces import IAuthenticatedPrincipalEvent, IProtectedObject
+from pyams_security.interfaces import IAuthenticatedPrincipalEvent, IProtectedObject, ADMIN_USER_ID, SYSTEM_ADMIN_ROLE
 
 # import packages
 from pyams_notify.event import Notification
@@ -54,7 +55,7 @@
     def get_target(self):
         root = self.context.request.root
         protection = IProtectedObject(root)
-        principals = {'system:admin'} | \
-                     protection.get_principals('system.Manager') | \
-                     protection.get_principals('pyams.Webmaster')
+        principals = {ADMIN_USER_ID} | \
+                     protection.get_principals(SYSTEM_ADMIN_ROLE) | \
+                     protection.get_principals(WEBMASTER_ROLE)
         return {'principals': tuple(principals)}