Use named permissions
authorThierry Florac <thierry.florac@onf.fr>
Thu, 08 Oct 2015 10:01:29 +0200
changeset 16 26640dcbe036
parent 15 7dc15c25739e
child 17 d56eef10d01a
Use named permissions
src/pyams_alchemy/zmi/engine.py
--- a/src/pyams_alchemy/zmi/engine.py	Wed Jul 22 16:44:23 2015 +0200
+++ b/src/pyams_alchemy/zmi/engine.py	Thu Oct 08 10:01:29 2015 +0200
@@ -20,6 +20,7 @@
 from pyams_form.interfaces.form import IWidgetsSuffixViewletsManager
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, ITableItemColumnActionsMenu
 from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION, MANAGE_SYSTEM_PERMISSION
 from pyams_zmi.layer import IAdminLayer
 from z3c.form.interfaces import IDataExtractedEvent, DISPLAY_MODE
 from zope.component.interfaces import ISite
@@ -48,7 +49,7 @@
 
 
 @viewlet_config(name='add-sqlalchemy-engine.menu', context=ISite, layer=IAdminLayer,
-                view=UtilitiesTable, manager=IToolbarAddingMenu, permission='system.manage')
+                view=UtilitiesTable, manager=IToolbarAddingMenu, permission=MANAGE_SYSTEM_PERMISSION)
 class AlchemyEngineAddMenu(ToolbarMenuItem):
     """SQLAlchemy engine add menu"""
 
@@ -58,7 +59,7 @@
     modal_target = True
 
 
-@pagelet_config(name='add-sqlalchemy-engine.html', context=ISite, layer=IPyAMSLayer, permission='system.manage')
+@pagelet_config(name='add-sqlalchemy-engine.html', context=ISite, layer=IPyAMSLayer, permission=MANAGE_SYSTEM_PERMISSION)
 class AlchemyEngineAddForm(AdminDialogAddForm):
     """SQLAlchemy engine add form"""
 
@@ -95,12 +96,13 @@
 
 
 @view_config(name='add-sqlalchemy-engine.json', context=ISite, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class AlchemyEngineAJAXAddForm(AJAXAddForm, AlchemyEngineAddForm):
     """SQLAlchemy engine add form, AJAX view"""
 
 
-@pagelet_config(name='properties.html', context=IAlchemyEngineUtility, layer=IPyAMSLayer, permission='system.view')
+@pagelet_config(name='properties.html', context=IAlchemyEngineUtility, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
 class AlchemyEnginePropertiesEditForm(AdminDialogEditForm):
     """SQLAlchemy engine properties edit form"""
 
@@ -114,7 +116,7 @@
 
     fields = field.Fields(IAlchemyEngineUtility)
     ajax_handler = 'properties.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(AlchemyEnginePropertiesEditForm, self).updateWidgets(prefix)
@@ -123,13 +125,13 @@
 
 
 @view_config(name='properties.json', context=IAlchemyEngineUtility, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class AlchemyEnginePropertiesAJAXEditForm(AJAXEditForm, AlchemyEnginePropertiesEditForm):
     """SQLAlchemy engine properties edit form, AJAX view"""
 
 
 @viewlet_config(name='test-engine.menu', context=IAlchemyEngineUtility, layer=IAdminLayer,
-                view=UtilitiesTable, manager=ITableItemColumnActionsMenu, permission='system.manage')
+                view=UtilitiesTable, manager=ITableItemColumnActionsMenu, permission=MANAGE_SYSTEM_PERMISSION)
 class AlchemyEngineTestMenu(ToolbarMenuItem):
     """SQLAlchemy engine test menu"""
 
@@ -155,7 +157,7 @@
 
 
 @pagelet_config(name='test-sqlalchemy-engine.html', context=IAlchemyEngineUtility, layer=IPyAMSLayer,
-                permission='system.manage')
+                permission=MANAGE_SYSTEM_PERMISSION)
 class AlchemyEngineTestForm(AdminDialogAddForm):
     """SQLAlchemy engine test form"""
 
@@ -170,7 +172,7 @@
     fields = field.Fields(IAlchemyEngineTestFields)
     buttons = button.Buttons(IAlchemyEngineTestButtons)
     ajax_handler = 'test-sqlalchemy-engine.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     @property
     def form_target(self):
@@ -232,7 +234,7 @@
 
 
 @view_config(name='test-sqlalchemy-engine.json', context=IAlchemyEngineUtility, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class AlchemyEngineAJAXTestForm(AJAXAddForm, AlchemyEngineTestForm):
     """Alchemy engine test form, AJAX view"""