Use constants for permissions
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 14:41:49 +0200
changeset 125 ff0be61d49a6
parent 124 9661ccbc94d8
child 126 00e660aa11a0
Use constants for permissions
src/pyams_content/__init__.py
--- a/src/pyams_content/__init__.py	Wed Aug 02 14:48:18 2017 +0200
+++ b/src/pyams_content/__init__.py	Mon Sep 11 14:41:49 2017 +0200
@@ -27,8 +27,10 @@
         CREATE_CONTENT_PERMISSION, MANAGE_CONTENT_PERMISSION, COMMENT_CONTENT_PERMISSION, PUBLISH_CONTENT_PERMISSION
     from pyams_content.interfaces import WEBMASTER_ROLE, PILOT_ROLE, MANAGER_ROLE, OWNER_ROLE, CONTRIBUTOR_ROLE, \
         READER_ROLE, OPERATOR_ROLE, GUEST_ROLE
+    from pyams_security.interfaces import ADMIN_USER_ID
+    from pyams_thesaurus.interfaces import CREATE_THESAURUS_PERMISSION, ADMIN_THESAURUS_PERMISSION
     from pyams_utils.interfaces import PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION, \
-        VIEW_SYSTEM_PERMISSION, MANAGE_SECURITY_PERMISSION, MANAGE_ROLES_PERMISSION, MANAGE_SKIN_PERMISSION
+        VIEW_SYSTEM_PERMISSION, MANAGE_ROLES_PERMISSION, MANAGE_SKIN_PERMISSION
 
     # register custom permissions
     config.register_permission({'id': MANAGE_SITE_ROOT_PERMISSION,
@@ -50,11 +52,12 @@
     config.register_role({'id': WEBMASTER_ROLE,
                           'title': _("Webmaster (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
-                                          VIEW_SYSTEM_PERMISSION, MANAGE_SECURITY_PERMISSION, MANAGE_ROLES_PERMISSION,
+                                          VIEW_SYSTEM_PERMISSION, MANAGE_ROLES_PERMISSION,
+                                          CREATE_THESAURUS_PERMISSION, ADMIN_THESAURUS_PERMISSION,
                                           MANAGE_SITE_ROOT_PERMISSION, MANAGE_SITE_PERMISSION, MANAGE_TOOL_PERMISSION,
                                           CREATE_CONTENT_PERMISSION, MANAGE_CONTENT_PERMISSION, MANAGE_SKIN_PERMISSION,
                                           COMMENT_CONTENT_PERMISSION, PUBLISH_CONTENT_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster'}})
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager', 'role:pyams.Webmaster'}})
     config.register_role({'id': PILOT_ROLE,
                           'title': _("Pilot (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
@@ -62,16 +65,16 @@
                                           MANAGE_SITE_PERMISSION, MANAGE_TOOL_PERMISSION,
                                           MANAGE_CONTENT_PERMISSION, COMMENT_CONTENT_PERMISSION,
                                           PUBLISH_CONTENT_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster'}})
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager', 'role:pyams.Webmaster'}})
     config.register_role({'id': MANAGER_ROLE,
                           'title': _("Manager (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
                                           VIEW_SYSTEM_PERMISSION, MANAGE_CONTENT_PERMISSION,
                                           COMMENT_CONTENT_PERMISSION, PUBLISH_CONTENT_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster',
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager', 'role:pyams.Webmaster',
                                        'role:pyams.Pilot'}})
     config.register_role({'id': OWNER_ROLE,
-                          'title': _("Creator (role)"),
+                          'title': _("Owner (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
                                           VIEW_SYSTEM_PERMISSION, MANAGE_ROLES_PERMISSION,
                                           MANAGE_CONTENT_PERMISSION, COMMENT_CONTENT_PERMISSION}})
@@ -81,20 +84,20 @@
                                           VIEW_SYSTEM_PERMISSION,
                                           CREATE_CONTENT_PERMISSION, MANAGE_CONTENT_PERMISSION,
                                           COMMENT_CONTENT_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster',
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager', 'role:pyams.Webmaster',
                                        'role:pyams.Pilot', 'role:pyams.Owner'}})
     config.register_role({'id': READER_ROLE,
                           'title': _("Reader (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
                                           VIEW_SYSTEM_PERMISSION, COMMENT_CONTENT_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster',
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager', 'role:pyams.Webmaster',
                                        'role:pyams.Pilot', 'role:pyams.Manager', 'role:pyams.Contributor'}})
     config.register_role({'id': OPERATOR_ROLE,
                           'title': _("Operator (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager'}})
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager'}})
     config.register_role({'id': GUEST_ROLE,
                           'title': _("Guest user (role)"),
                           'permissions': {PUBLIC_PERMISSION, VIEW_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster',
+                          'managers': {ADMIN_USER_ID, 'role:system.Manager', 'role:pyams.Webmaster',
                                        'role:pyams.Pilot', 'role:pyams.Manager', 'role:pyams.Contributor'}})