--- a/src/pyams_content/root/zmi/sites.py Mon Jun 04 16:43:56 2018 +0200
+++ b/src/pyams_content/root/zmi/sites.py Tue Jun 05 09:38:57 2018 +0200
@@ -155,11 +155,32 @@
return super(SiteTreeTrashColumn, self).has_permission(item) and item.is_deletable()
-@view_config(name='delete-shared-site.json', context=ISiteRoot, request_type=IPyAMSLayer,
+@view_config(name='delete-element.json', context=ISiteRoot, request_type=IPyAMSLayer,
permission=MANAGE_SITE_ROOT_PERMISSION, renderer='json', xhr=True)
def delete_shared_site(request):
"""Delete shared site from site manager"""
- if not request.context.is_deletable():
+ translate = request.localizer.translate
+ # Get object name to be removed
+ name = request.params.get('object_name')
+ if not name:
+ return {
+ 'status': 'message',
+ 'messagebox': {
+ 'status': 'error',
+ 'content': translate(_("No provided object_name argument!"))
+ }
+ }
+ # Check context
+ if name not in request.context:
+ return {
+ 'status': 'message',
+ 'messagebox': {
+ 'status': 'error',
+ 'content': translate(_("Given element name doesn't exist!"))
+ }
+ }
+ context = request.context[name]
+ if not context.is_deletable():
raise NotFound()
return delete_container_element(request, ignore_permission=True)