Use constants for roles
authorThierry Florac <thierry.florac@onf.fr>
Tue, 26 Jun 2018 15:00:38 +0200
changeset 130 bb4c55385b4a
parent 129 df7d8dae5e0d
child 131 5f42c1b3365f
Use constants for roles
src/pyams_security/__init__.py
src/pyams_security/interfaces/__init__.py
--- a/src/pyams_security/__init__.py	Mon Jun 11 16:09:15 2018 +0200
+++ b/src/pyams_security/__init__.py	Tue Jun 26 15:00:38 2018 +0200
@@ -24,7 +24,7 @@
 from pyramid.i18n import TranslationStringFactory
 _ = TranslationStringFactory('pyams_security')
 
-from pyams_security.interfaces import ADMIN_USER_ID
+from pyams_security.interfaces import ADMIN_USER_ID, SYSTEM_ADMIN_ROLE
 from pyams_utils.interfaces import PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION, VIEW_SYSTEM_PERMISSION, \
     MANAGE_SYSTEM_PERMISSION, MANAGE_SECURITY_PERMISSION, MANAGE_ROLES_PERMISSION, MANAGE_SKIN_PERMISSION
 
@@ -55,9 +55,9 @@
                                 'title': _("Manage roles")})
 
     # register custom roles
-    config.register_role({'id': 'system.Manager',
+    config.register_role({'id': SYSTEM_ADMIN_ROLE,
                           'title': "System manager (role)",
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
                                           MANAGE_SYSTEM_PERMISSION, VIEW_SYSTEM_PERMISSION, MANAGE_SECURITY_PERMISSION,
                                           MANAGE_SKIN_PERMISSION, MANAGE_ROLES_PERMISSION},
-                          'managers': {ADMIN_USER_ID, 'role:system.Manager'}})
+                          'managers': {ADMIN_USER_ID, 'role:{0}'.format(SYSTEM_ADMIN_ROLE)}})
--- a/src/pyams_security/interfaces/__init__.py	Mon Jun 11 16:09:15 2018 +0200
+++ b/src/pyams_security/interfaces/__init__.py	Tue Jun 26 15:00:38 2018 +0200
@@ -41,6 +41,8 @@
 INTERNAL_USER_LOGIN = 'internal'
 INTERNAL_USER_ID = '{0}:{1}'.format(SYSTEM_PREFIX, INTERNAL_USER_LOGIN)
 
+SYSTEM_ADMIN_ROLE = 'system.Manager'
+
 
 #
 # Permissions constants and interfaces