Use named permissions
authorThierry Florac <thierry.florac@onf.fr>
Wed, 07 Oct 2015 17:48:39 +0200
changeset 50 f4e90f45ebb3
parent 49 01eaa997a5f4
child 51 56fc7fc505d3
Use named permissions
src/pyams_utils/zmi/timezone.py
src/pyams_utils/zmi/zeo.py
--- a/src/pyams_utils/zmi/timezone.py	Wed Oct 07 17:48:04 2015 +0200
+++ b/src/pyams_utils/zmi/timezone.py	Wed Oct 07 17:48:39 2015 +0200
@@ -16,8 +16,9 @@
 # import standard library
 
 # import interfaces
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION, MANAGE_SYSTEM_PERMISSION
+from pyams_utils.interfaces.timezone import IServerTimezone
 from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces.timezone import IServerTimezone
 
 # import packages
 from pyams_form.form import AJAXEditForm
@@ -30,13 +31,14 @@
 
 
 @pagelet_config(name='properties.html', context=IServerTimezone, layer=IPyAMSLayer,
-                permission='system.view')
+                permission=VIEW_SYSTEM_PERMISSION)
 class ServerTimezonePropertiesEditForm(AdminDialogEditForm):
     """Server timezone properties edit form"""
 
     legend = _("Update server timezone properties")
     fields = field.Fields(IServerTimezone)
     ajax_handler = 'properties.json'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     @property
     def title(self):
@@ -48,6 +50,6 @@
 
 
 @view_config(name='properties.json', context=IServerTimezone, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class ServerTimezonePropertiesAJAXEditForm(AJAXEditForm, ServerTimezonePropertiesEditForm):
     """Server timezone properties edit form, AJAX renderer"""
--- a/src/pyams_utils/zmi/zeo.py	Wed Oct 07 17:48:04 2015 +0200
+++ b/src/pyams_utils/zmi/zeo.py	Wed Oct 07 17:48:39 2015 +0200
@@ -19,6 +19,7 @@
 from pyams_skin.interfaces.container import ITableElementName
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
 from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION, MANAGE_SYSTEM_PERMISSION
 from pyams_utils.interfaces.zeo import IZEOConnection
 from pyams_zmi.layer import IAdminLayer
 from z3c.form.interfaces import IDataExtractedEvent, DISPLAY_MODE
@@ -54,7 +55,7 @@
 
 
 @viewlet_config(name='add-zeo-connection.menu', context=ISite, layer=IAdminLayer,
-                view=UtilitiesTable, manager=IToolbarAddingMenu, permission='system.manage')
+                view=UtilitiesTable, manager=IToolbarAddingMenu, permission=MANAGE_SYSTEM_PERMISSION)
 class ZEOConnectionAddMenu(ToolbarMenuItem):
     """ZEO connection add menu"""
 
@@ -64,7 +65,7 @@
     modal_target = True
 
 
-@pagelet_config(name='add-zeo-connection.html', context=ISite, layer=IPyAMSLayer, permission='system.manage')
+@pagelet_config(name='add-zeo-connection.html', context=ISite, layer=IPyAMSLayer, permission=MANAGE_SYSTEM_PERMISSION)
 class ZEOConnectionAddForm(AdminDialogAddForm):
     """ZEO connection add form"""
 
@@ -101,12 +102,12 @@
 
 
 @view_config(name='add-zeo-connection.json', context=ISite, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class ZEOConnectionAJAXAddForm(AJAXAddForm, ZEOConnectionAddForm):
     """ZEO connection add form, AJAX view"""
 
 
-@pagelet_config(name='properties.html', context=IZEOConnection, layer=IPyAMSLayer, permission='system.view')
+@pagelet_config(name='properties.html', context=IZEOConnection, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
 class ZEOConnectionPropertiesEditForm(AdminDialogEditForm):
     """ZEO connection properties edit form"""
 
@@ -121,7 +122,7 @@
     fields = field.Fields(IZEOConnection)
     autocomplete = 'off'
     ajax_handler = 'properties.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(ZEOConnectionPropertiesEditForm, self).updateWidgets(prefix)
@@ -129,6 +130,6 @@
 
 
 @view_config(name='properties.json', context=IZEOConnection, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class ZEOConnectionPropertiesAJAXEditForm(AJAXEditForm, ZEOConnectionPropertiesEditForm):
     """ZEO connection properties edit form, AJAX view"""