src/pyams_security/zmi/plugin/social.py
changeset 54 59683c264d94
parent 42 07229ac2497b
child 65 e2733978d478
--- a/src/pyams_security/zmi/plugin/social.py	Thu Oct 08 09:30:56 2015 +0200
+++ b/src/pyams_security/zmi/plugin/social.py	Thu Oct 08 09:31:45 2015 +0200
@@ -22,6 +22,7 @@
 from pyams_skin.interfaces import IPageHeader, IInnerPage
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IWidgetTitleViewletManager
 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 DISPLAY_MODE, IDataExtractedEvent
 from z3c.table.interfaces import IColumn, IValues
@@ -62,7 +63,7 @@
 
 @viewlet_config(name='add-social-users-folder.menu', context=ISite, layer=IAdminLayer,
                 view=SecurityManagerPluginsTable, manager=IToolbarAddingMenu,
-                permission='system.manage', weight=50)
+                permission=MANAGE_SYSTEM_PERMISSION, weight=50)
 class SocialUsersFolderAddMenu(ToolbarMenuItem):
     """Social users folder add menu"""
 
@@ -73,7 +74,7 @@
 
 
 @pagelet_config(name='add-social-users-folder.html', context=ISite, layer=IPyAMSLayer,
-                permission='system.manage')
+                permission=MANAGE_SYSTEM_PERMISSION)
 class SocialUsersFolderAddForm(AdminDialogAddForm):
     """Social users folder plug-in add form"""
 
@@ -83,7 +84,7 @@
 
     fields = field.Fields(ISocialUsersFolderPlugin).omit('__name__', '__parent__')
     ajax_handler = 'add-social-users-folder.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def create(self, data):
         return SocialUsersFolder()
@@ -106,13 +107,13 @@
 
 
 @view_config(name='add-social-users-folder.json', context=ISite, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class SocialUsersFolderAJAXAddForm(AJAXAddForm, SocialUsersFolderAddForm):
     """Social users folder plug-in add form, AJAX handler"""
 
 
 @pagelet_config(name='properties.html', context=ISocialUsersFolderPlugin, layer=IPyAMSLayer,
-                permission='system.view')
+                permission=VIEW_SYSTEM_PERMISSION)
 class SocialUsersFolderEditForm(AdminDialogEditForm):
     """Social users folder plug-in edit form"""
 
@@ -125,7 +126,7 @@
 
     fields = field.Fields(ISocialUsersFolderPlugin).omit('__name__', '__parent__')
     ajax_handler = 'properties.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(SocialUsersFolderEditForm, self).updateWidgets()
@@ -133,7 +134,7 @@
 
 
 @view_config(name='properties.json', context=ISocialUsersFolderPlugin, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class SocialUsersFolderAJAXEditForm(AJAXEditForm, SocialUsersFolderEditForm):
     """Social users folder plug-in edit form, AJAX handler"""
 
@@ -142,7 +143,8 @@
 # Social users folder search views
 #
 
-@pagelet_config(name='search.html', context=ISocialUsersFolderPlugin, layer=IPyAMSLayer, permission='system.view')
+@pagelet_config(name='search.html', context=ISocialUsersFolderPlugin, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
 class SocialUsersFolderSearchView(AdminView, SearchView):
     """Social users folder search view"""
     
@@ -165,7 +167,7 @@
 
 
 @view_config(name='search-results.html', context=ISocialUsersFolderPlugin, request_type=IPyAMSLayer,
-             permission='system.view')
+             permission=VIEW_SYSTEM_PERMISSION)
 class SocialUsersFolderSearchResultsView(AdminView, SearchResultsView):
     """Social users folder search results view table"""
 
@@ -238,7 +240,7 @@
 # Social users views
 #
 
-@pagelet_config(name='properties.html', context=ISocialUser, layer=IPyAMSLayer, permission='system.view')
+@pagelet_config(name='properties.html', context=ISocialUser, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
 class SocialUserEditForm(AdminDialogEditForm):
     """Social user edit form"""
 
@@ -254,7 +256,7 @@
     fields = field.Fields(ISocialUser).omit('__parent__', '__name__', 'attributes')
 
     ajax_handler = 'properties.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(SocialUserEditForm, self).updateWidgets()
@@ -264,7 +266,7 @@
 
 
 @view_config(name='properties.json', context=ISocialUser, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class SocialUserAJAXEditForm(AJAXEditForm, SocialUserEditForm):
     """Social user edit form, AJAX view"""
 
@@ -274,7 +276,7 @@
 #
 
 @viewlet_config(name='security-manager.social.menu', context=ISite, layer=IAdminLayer,
-                manager=ISecurityManagerMenu, permission='system.view', weight=10)
+                manager=ISecurityManagerMenu, permission=VIEW_SYSTEM_PERMISSION, weight=10)
 class SecurityManagerSocialMenuItem(MenuItem):
     """Security manager social menu"""
 
@@ -336,7 +338,7 @@
     """Security manager plugins trash column"""
 
     icon_hint = _("Delete provider")
-    permission = 'system.manage'
+    permission = MANAGE_SYSTEM_PERMISSION
 
 
 @adapter_config(context=(ISite, IAdminLayer, SecurityManagerSocialProvidersTable), provides=IValues)
@@ -352,7 +354,7 @@
         return ()
 
 
-@pagelet_config(name='social-providers.html', context=ISite, layer=IPyAMSLayer, permission='system.view')
+@pagelet_config(name='social-providers.html', context=ISite, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
 @implementer(IInnerPage)
 class SecurityManagerSocialProvidersView(AdminView, ContainerView):
     """Security manager social providers view"""
@@ -373,7 +375,7 @@
 
 
 @viewlet_config(name='security-manager.social.adding', context=ISite, view=SecurityManagerSocialProvidersTable,
-                layer=IAdminLayer, manager=IWidgetTitleViewletManager, permission='system.manage')
+                layer=IAdminLayer, manager=IWidgetTitleViewletManager, permission=MANAGE_SYSTEM_PERMISSION)
 class SocialToolbarAddingsAction(ToolbarAction):
     """Security manager social toolbar adding action"""
 
@@ -382,7 +384,7 @@
     modal_target = True
 
 
-@pagelet_config(name='add-social-provider.html', context=ISite, layer=IPyAMSLayer, permission='system.manage')
+@pagelet_config(name='add-social-provider.html', context=ISite, layer=IPyAMSLayer, permission=MANAGE_SYSTEM_PERMISSION)
 class SocialProviderAddForm(AdminDialogAddForm):
     """Social provider add form"""
 
@@ -395,7 +397,7 @@
     fields = field.Fields(ISocialLoginProviderConnection).omit('__parent__', '__name__')
 
     ajax_handler = 'add-social-provider.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(SocialProviderAddForm, self).updateWidgets()
@@ -425,7 +427,7 @@
 
 
 @view_config(name='add-social-provider.json', context=ISite, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class SocialProviderAJAXAddForm(AJAXAddForm, SocialProviderAddForm):
     """Social provider add form, AJAX view"""
 
@@ -437,7 +439,7 @@
 
 
 @pagelet_config(name='properties.html', context=ISocialLoginProviderConnection, layer=IPyAMSLayer,
-                permission='system.view')
+                permission=VIEW_SYSTEM_PERMISSION)
 class SocialProviderEditForm(AdminDialogEditForm):
     """Social provider edit form"""
 
@@ -450,7 +452,7 @@
     fields = field.Fields(ISocialLoginProviderConnection).omit('__parent__', '__name__')
 
     ajax_handler = 'properties.json'
-    edit_permission = 'system.manage'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(SocialProviderEditForm, self).updateWidgets()
@@ -459,13 +461,13 @@
 
 
 @view_config(name='properties.json', context=ISocialLoginProviderConnection, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class SocialProviderAJAXEditForm(AJAXEditForm, SocialProviderEditForm):
     """Social provider edit form, AJAX view"""
 
 
 @view_config(name='delete-provider.json', context=ISocialLoginConfiguration, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 def delete_social_provider(request):
     """Delete social provider from security manager"""
     translate = request.localizer.translate