--- a/src/pyams_skin/container.py Wed May 20 12:33:54 2015 +0200
+++ b/src/pyams_skin/container.py Wed May 20 12:34:23 2015 +0200
@@ -18,12 +18,16 @@
# import interfaces
from pyams_skin.interfaces.container import IContainerBaseView
from pyams_skin.layer import IPyAMSLayer
+from zope.container.interfaces import IContainer
# import packages
from pyams_skin.table import BaseTable
from pyams_template.template import template_config
+from pyramid.view import view_config
from zope.interface import implementer
+from pyams_utils import _
+
@template_config(template='templates/container.pt', layer=IPyAMSLayer)
@implementer(IContainerBaseView)
@@ -39,3 +43,21 @@
def update(self):
super(ContainerView, self).update()
self.table.update()
+
+
+@view_config(name='delete-element.json', context=IContainer, request_type=IPyAMSLayer,
+ permission='manage', renderer='json', xhr=True)
+def delete_container_element(request):
+ """Delete container element"""
+ translate = request.localizer.translate
+ name = request.params.get('object_name')
+ if not name:
+ return {'status': 'message',
+ 'messagebox': {'status': 'error',
+ 'content': translate(_("No provided object_name argument!"))}}
+ if name not in request.context:
+ return {'status': 'message',
+ 'messagebox': {'status': 'error',
+ 'content': translate(_("Given plug-in name doesn't exist!"))}}
+ del request.context[name]
+ return {'status': 'success'}