Added constants for system users login name and id
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 13:55:37 +0200
changeset 93 be0b2504aaf3
parent 92 4489af75f076
child 94 01d611aa7891
Added constants for system users login name and id
src/pyams_security/__init__.py
src/pyams_security/profile.py
src/pyams_security/security.py
src/pyams_security/zmi/utility.py
--- a/src/pyams_security/__init__.py	Mon Sep 11 13:54:44 2017 +0200
+++ b/src/pyams_security/__init__.py	Mon Sep 11 13:55:37 2017 +0200
@@ -24,6 +24,7 @@
 from pyramid.i18n import TranslationStringFactory
 _ = TranslationStringFactory('pyams_security')
 
+from pyams_security.interfaces import ADMIN_USER_ID
 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
 
@@ -59,4 +60,4 @@
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
                                           MANAGE_SYSTEM_PERMISSION, VIEW_SYSTEM_PERMISSION, MANAGE_SECURITY_PERMISSION,
                                           MANAGE_SKIN_PERMISSION, MANAGE_ROLES_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager'}})
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager'}})
--- a/src/pyams_security/profile.py	Mon Sep 11 13:54:44 2017 +0200
+++ b/src/pyams_security/profile.py	Mon Sep 11 13:55:37 2017 +0200
@@ -16,7 +16,7 @@
 # import standard library
 
 # import interfaces
-from pyams_security.interfaces import IPrincipalInfo
+from pyams_security.interfaces import IPrincipalInfo, ADMIN_USER_ID
 from pyams_security.interfaces.profile import PUBLIC_PROFILE_KEY, IPublicProfile
 from pyams_utils.interfaces import PUBLIC_PERMISSION
 from pyams_utils.interfaces.tales import ITALESExtension
@@ -45,7 +45,7 @@
     avatar = FileProperty(IPublicProfile['avatar'])
 
     def __acl__(self):
-        result = [(Allow, 'system:admin', ALL_PERMISSIONS)]
+        result = [(Allow, ADMIN_USER_ID, ALL_PERMISSIONS)]
         request = query_request()
         if request is not None:
             result.append((Allow, request.principal.id, ALL_PERMISSIONS))
--- a/src/pyams_security/security.py	Mon Sep 11 13:54:44 2017 +0200
+++ b/src/pyams_security/security.py	Mon Sep 11 13:55:37 2017 +0200
@@ -18,7 +18,7 @@
 
 # import interfaces
 from pyams_security.interfaces import IProtectedObject, IRole, IPrincipalInfo, GrantedRoleEvent, RevokedRoleEvent, \
-    IDefaultProtectionPolicy, IRoleProtectedObject
+    IDefaultProtectionPolicy, IRoleProtectedObject, ADMIN_USER_ID
 from zope.annotation.interfaces import IAnnotations
 
 # import packages
@@ -170,7 +170,7 @@
     @request_property(key=None)
     def __acl__(self):
         # always grant all permissions to system manager
-        result = [(Allow, 'system:admin', ALL_PERMISSIONS)]
+        result = [(Allow, ADMIN_USER_ID, ALL_PERMISSIONS)]
         # grant access to all roles permissions
         for role_id in self.get_granted_roles():
             role = query_utility(IRole, role_id)
--- a/src/pyams_security/zmi/utility.py	Mon Sep 11 13:54:44 2017 +0200
+++ b/src/pyams_security/zmi/utility.py	Mon Sep 11 13:55:37 2017 +0200
@@ -16,7 +16,7 @@
 # import standard library
 
 # import interfaces
-from pyams_security.interfaces import ISecurityManager, IDirectorySearchPlugin
+from pyams_security.interfaces import ISecurityManager, IDirectorySearchPlugin, SYSTEM_PREFIX
 from pyams_security.zmi.interfaces import ISecurityManagerMenu
 from pyams_skin.interfaces import IInnerPage, IPageHeader
 from pyams_skin.interfaces.container import ITableElementEditor
@@ -130,7 +130,7 @@
     icon_hint = _("Delete plug-in")
     permission = MANAGE_SECURITY_PERMISSION
 
-    checker = lambda col, x: x.__name__ != '__system__'
+    checker = lambda col, x: x.prefix != SYSTEM_PREFIX
 
 
 @adapter_config(context=(ISite, IAdminLayer, SecurityManagerPluginsTable), provides=IValues)
@@ -158,7 +158,6 @@
     """Security manager header adapter"""
 
     icon_class = 'fa fa-fw fa-lock'
-    title = _("Control panel")
     subtitle = _("Security manager")