User generic PyAMS skin functions
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Mar 2015 16:42:45 +0100
changeset 20 c4259361b1b1
parent 19 cccce8238bd7
child 21 f4c64d963935
User generic PyAMS skin functions
src/pyams_security/zmi/utility.py
--- a/src/pyams_security/zmi/utility.py	Tue Mar 03 16:42:15 2015 +0100
+++ b/src/pyams_security/zmi/utility.py	Tue Mar 03 16:42:45 2015 +0100
@@ -17,10 +17,9 @@
 
 # import interfaces
 from pyams_security.interfaces import ISecurityManager, IDirectorySearchPlugin
-from pyams_security.zmi.interfaces import ISecurityManagerMenu, ISecurityManagerToolbarAddingMenu
+from pyams_security.zmi.interfaces import ISecurityManagerMenu
 from pyams_skin.interfaces import IInnerPage, IPageHeader
 from pyams_skin.interfaces.container import ITableElementEditor
-from pyams_skin.interfaces.viewlet import IToolbarViewletManager
 from pyams_skin.layer import IPyAMSLayer
 from pyams_zmi.interfaces.menu import IControlPanelMenu
 from pyams_zmi.layer import IAdminLayer
@@ -33,9 +32,8 @@
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_security.zmi.widget import OrderedPluginsFieldWidget
 from pyams_skin.container import ContainerView
-from pyams_skin.table import BaseTable, DefaultElementEditorAdapter, ActionColumn, I18nColumn
+from pyams_skin.table import BaseTable, DefaultElementEditorAdapter, ActionColumn, I18nColumn, TrashColumn
 from pyams_skin.viewlet.menu import MenuItem
-from pyams_skin.viewlet.toolbar import ToolbarMenu
 from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
 from pyams_utils.registry import query_utility
 from pyams_utils.traversing import get_parent
@@ -91,8 +89,7 @@
         manager = query_utility(ISecurityManager)
         attributes = super(SecurityManagerPluginsTable, self).data_attributes
         table_attrs = {'data-ams-location': absolute_url(manager, self.request),
-                       'data-ams-plugins': 'pyams_security',
-                       'data-ams-plugin-pyams_security-src': '/--static--/pyams_security/js/security.js'}
+                       'data-ams-delete-target': 'delete-plugin.json'}
         if 'table' in attributes:
             attributes['table'].update(table_attrs)
         else:
@@ -126,22 +123,13 @@
 
 
 @adapter_config(name='trash', context=(Interface, IAdminLayer, SecurityManagerPluginsTable), provides=IColumn)
-class SecurityManagerPluginsTrashColumn(ActionColumn):
+class SecurityManagerPluginsTrashColumn(TrashColumn):
     """Security manager plugins trash column"""
 
-    url = "PyAMS_security.plugins.deletePlugin"
-    icon_class = 'fa fa-fw fa-trash'
     icon_hint = _("Delete plug-in")
-    weight = 100
     permission = 'system.manage'
 
-    def renderCell(self, item):
-        if item.__name__ == '__system__':  # can't delete system manager login plug-in!!
-            return ''
-        return super(SecurityManagerPluginsTrashColumn, self).renderCell(item)
-
-    def get_url(self, item):
-        return self.url
+    checker = lambda col, x: x.__name__ != '__system__'
 
 
 @adapter_config(context=(ISite, IAdminLayer, SecurityManagerPluginsTable), provides=IValues)
@@ -176,17 +164,6 @@
     subtitle = _("Security manager plug-ins")
 
 
-@viewlet_config(name='security-manager.toolbar.adding', context=ISite, view=SecurityManagerPluginsTable,
-                layer=IAdminLayer, manager=IToolbarViewletManager, permission='system.manage')
-@viewletmanager_config(name='security-manager.toolbar.adding', context=ISite, view=SecurityManagerPluginsTable,
-                       layer=IAdminLayer)
-@implementer(ISecurityManagerToolbarAddingMenu)
-class SecurityManagerToolbarAddingsAction(ToolbarMenu):
-    """Security manager toolbar adding action"""
-
-    label = _("Add...")
-
-
 @viewlet_config(name='security-manager.properties.menu', context=ISite, layer=IAdminLayer,
                 manager=ISecurityManagerMenu, permission='system.view', weight=1)
 class SecurityManagerPropertiesMenuItem(MenuItem):
@@ -261,11 +238,11 @@
 def delete_security_manager_plugin(request):
     """Delete plug-in from security manager"""
     translate = request.localizer.translate
-    name = request.params.get('plugin_name')
+    name = request.params.get('object_name')
     if not name:
         return {'status': 'message',
                 'messagebox': {'status': 'error',
-                               'content': translate(_("No provided plugin_name argument!"))}}
+                               'content': translate(_("No provided object_name argument!"))}}
     if name not in request.context:
         return {'status': 'message',
                 'messagebox': {'status': 'error',