Use constants for roles
authorThierry Florac <thierry.florac@onf.fr>
Tue, 26 Jun 2018 15:00:06 +0200
changeset 141 2ac6f3379d14
parent 140 95bee9c0ae3f
child 142 e5e3406cf037
Use constants for roles
src/pyams_portal/__init__.py
src/pyams_portal/interfaces/__init__.py
--- a/src/pyams_portal/__init__.py	Tue Jun 26 12:11:24 2018 +0200
+++ b/src/pyams_portal/__init__.py	Tue Jun 26 15:00:06 2018 +0200
@@ -16,6 +16,7 @@
 from fanstatic import Library, Resource
 library = Library('pyams_portal', 'resources')
 
+
 pyams_portal_css = Resource(library, 'css/portal.css',
                             minified='css/portal.min.css')
 
@@ -28,13 +29,15 @@
 from pyramid.i18n import TranslationStringFactory
 _ = TranslationStringFactory('pyams_portal')
 
-from pyams_portal.interfaces import MANAGE_TEMPLATE_PERMISSION
-from pyams_utils.interfaces import VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION
-
 
 def includeme(config):
     """Pyramid include"""
 
+    from pyams_content.interfaces import WEBMASTER_ROLE
+    from pyams_portal.interfaces import MANAGE_TEMPLATE_PERMISSION, DESIGNER_ROLE
+    from pyams_security.interfaces import ADMIN_USER_ID, SYSTEM_ADMIN_ROLE
+    from pyams_utils.interfaces import VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION
+
     from .include import include_package
     include_package(config)
 
@@ -43,7 +46,9 @@
                                 'title': _("Manage portal templates")})
 
     # register custom roles
-    config.register_role({'id': 'pyams.TemplatesManager',
+    config.register_role({'id': DESIGNER_ROLE,
                           'title': _("Portal templates manager"),
                           'permissions': {MANAGE_TEMPLATE_PERMISSION, VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
-                          'managers': {'system:admin', 'role:system.Manager', 'role:pyams.Webmaster'}})
+                          'managers': {ADMIN_USER_ID,
+                                       'role:{0}'.format(SYSTEM_ADMIN_ROLE),
+                                       'role:{0}'.format(WEBMASTER_ROLE)}})
--- a/src/pyams_portal/interfaces/__init__.py	Tue Jun 26 12:11:24 2018 +0200
+++ b/src/pyams_portal/interfaces/__init__.py	Tue Jun 26 15:00:06 2018 +0200
@@ -33,6 +33,9 @@
 
 MANAGE_TEMPLATE_PERMISSION = 'pyams_portal.manage_template'
 
+DESIGNER_ROLE = 'pyams.TemplatesManager'
+'''Designer role is allowed to manage presentation templates'''
+
 
 #
 # Portlet interfaces