--- a/src/pyams_security/zmi/notification.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/notification.py Wed Apr 11 11:40:14 2018 +0200
@@ -57,6 +57,8 @@
class SecurityManagerNotificationsEditForm(AdminDialogEditForm):
"""Security manager notifications edit form"""
+ prefix = 'security_notifications.'
+
title = _("System security manager")
legend = _("Notifications properties")
icon_css_class = 'fa fa-fw fa-envelope-o'
--- a/src/pyams_security/zmi/plugin/admin.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/plugin/admin.py Wed Apr 11 11:40:14 2018 +0200
@@ -102,6 +102,8 @@
class AdminAuthenticationEditForm(AdminDialogEditForm):
"""Admin authentication plug-in edit form"""
+ prefix = 'admin_properties.'
+
@property
def title(self):
return self.context.title
--- a/src/pyams_security/zmi/plugin/group.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/plugin/group.py Wed Apr 11 11:40:14 2018 +0200
@@ -110,6 +110,8 @@
class GroupsFolderEditForm(AdminDialogEditForm):
"""Groups folder plug-in edit form"""
+ prefix = 'groups_properties.'
+
@property
def title(self):
return self.context.title
@@ -270,15 +272,19 @@
def get_ajax_output(self, changes):
translate = self.request.localizer.translate
- return {'status': 'reload',
- 'location': absolute_url(self.context, self.request, 'search.html'),
- 'message': translate(_("Group was created successfully"))}
+ return {
+ 'status': 'reload',
+ 'location': absolute_url(self.context, self.request, 'search.html'),
+ 'message': translate(_("Group was created successfully"))
+ }
@pagelet_config(name='properties.html', context=ILocalGroup, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
class LocalGroupEditForm(AdminDialogEditForm):
"""Local group edit form"""
+ prefix = 'group_properties.'
+
@property
def title(self):
return self.context.title
@@ -306,7 +312,9 @@
def get_ajax_output(self, changes):
if 'title' in changes.get(ILocalGroup, ()):
- return {'status': 'reload',
- 'location': absolute_url(self.context.__parent__, self.request, 'search.html')}
+ return {
+ 'status': 'reload',
+ 'location': absolute_url(self.context.__parent__, self.request, 'search.html')
+ }
else:
return super(LocalGroupAJAXEditForm, self).get_ajax_output(changes)
--- a/src/pyams_security/zmi/plugin/social.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/plugin/social.py Wed Apr 11 11:40:14 2018 +0200
@@ -35,7 +35,7 @@
from pyams_pagelet.pagelet import pagelet_config
from pyams_security.plugin.social import SocialUsersFolder, SocialLoginProviderConnection, get_provider_info
from pyams_security.zmi.utility import SecurityManagerPluginsTable
-from pyams_skin.container import ContainerView
+from pyams_skin.container import ContainerView, delete_container_element
from pyams_skin.page import DefaultPageHeaderAdapter
from pyams_skin.skin import apply_skin
from pyams_skin.table import I18nColumn, BaseTable, ActionColumn, TrashColumn
@@ -117,6 +117,8 @@
class SocialUsersFolderEditForm(AdminDialogEditForm):
"""Social users folder plug-in edit form"""
+ prefix = 'social_properties.'
+
@property
def title(self):
return self.context.title
@@ -244,6 +246,8 @@
class SocialUserEditForm(AdminDialogEditForm):
"""Social user edit form"""
+ prefix = 'socialuser_properties.'
+
@property
def title(self):
return self.context.title
@@ -295,12 +299,18 @@
def data_attributes(self):
manager = query_utility(ISecurityManager)
if manager is not None:
- return {'table': {'data-ams-location': absolute_url(ISocialLoginConfiguration(manager), self.request),
- 'data-ams-delete-target': 'delete-provider.json'},
- 'tr': {'data-ams-element-name': lambda x, col: x.provider_name,
- 'data-ams-url': lambda x, col: absolute_url(x, self.request, 'properties.html'),
- 'data-toggle': 'modal'}}
- return {}
+ return {
+ 'table': {
+ 'data-ams-location': absolute_url(ISocialLoginConfiguration(manager), self.request)
+ },
+ 'tr': {
+ 'data-ams-element-name': lambda x, col: x.provider_name,
+ 'data-ams-url': lambda x, col: absolute_url(x, self.request, 'properties.html'),
+ 'data-toggle': 'modal'
+ }
+ }
+ else:
+ return {}
@adapter_config(name='icon', context=(Interface, IAdminLayer, SecurityManagerSocialProvidersTable), provides=IColumn)
@@ -341,6 +351,13 @@
permission = MANAGE_SYSTEM_PERMISSION
+@view_config(name='delete-element.json', context=ISocialLoginConfiguration, request_type=IPyAMSLayer,
+ permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
+def delete_social_provider(request):
+ """Delete social provider from security manager"""
+ return delete_container_element(request, ignore_permission=True)
+
+
@adapter_config(context=(ISite, IAdminLayer, SecurityManagerSocialProvidersTable), provides=IValues)
class SecurityManagerSocialProvidersValuesAdapter(ContextRequestViewAdapter):
"""Security manager social providers values adapter"""
@@ -434,9 +451,11 @@
def get_ajax_output(self, changes):
translate = self.request.localizer.translate
- return {'status': 'reload',
- 'location': absolute_url(self.context, self.request, 'social-providers.html'),
- 'message': translate(_("Social provider was created successfully"))}
+ return {
+ 'status': 'reload',
+ 'location': absolute_url(self.context, self.request, 'social-providers.html'),
+ 'message': translate(_("Social provider was created successfully"))
+ }
@pagelet_config(name='properties.html', context=ISocialLoginProviderConnection, layer=IPyAMSLayer,
@@ -444,6 +463,8 @@
class SocialProviderEditForm(AdminDialogEditForm):
"""Social provider edit form"""
+ prefix = 'provider_properties.'
+
title = _("Security manager")
legend = _("Edit social login provider properties")
icon_css_class = 'fa fa-fw fa-share-alt'
@@ -465,21 +486,3 @@
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=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
-def delete_social_provider(request):
- """Delete social provider from security manager"""
- translate = request.localizer.translate
- name = request.params.get('object_name')
- if not name:
- return {'status': 'message',
- 'messagebox': {'status': 'error',
- 'content': translate(_("No provided provider_name argument!"))}}
- if name not in request.context:
- return {'status': 'message',
- 'messagebox': {'status': 'error',
- 'content': translate(_("Given provider name doesn't exist!"))}}
- del request.context[name]
- return {'status': 'success'}
--- a/src/pyams_security/zmi/plugin/userfolder.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/plugin/userfolder.py Wed Apr 11 11:40:14 2018 +0200
@@ -114,6 +114,8 @@
class UsersFolderEditForm(AdminDialogEditForm):
"""Users folder plug-in edit form"""
+ prefix = 'users_properties.'
+
@property
def title(self):
return self.context.title
@@ -323,14 +325,18 @@
def get_ajax_output(self, changes):
translate = self.request.localizer.translate
- return {'status': 'success',
- 'message': translate(_("User was created successfully"))}
+ return {
+ 'status': 'success',
+ 'message': translate(_("User was created successfully"))
+ }
@pagelet_config(name='properties.html', context=ILocalUser, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
class LocalUserEditForm(AdminDialogEditForm):
"""Local user edit form"""
+ prefix = 'user_properties.'
+
@property
def title(self):
return self.context.title
--- a/src/pyams_security/zmi/profile.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/profile.py Wed Apr 11 11:40:14 2018 +0200
@@ -57,6 +57,8 @@
class UserProfileEditForm(AdminDialogEditForm):
"""User profile edit form"""
+ prefix = 'user_profile.'
+
legend = _("Edit user profile")
fields = field.Fields(Interface)
@@ -87,6 +89,8 @@
class PublicProfileTabForm(InnerAdminEditForm):
"""Public profile tab form"""
+ prefix = 'public_profile_form.'
+
tab_label = _("Public profile")
legend = None
--- a/src/pyams_security/zmi/security.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/security.py Wed Apr 11 11:40:14 2018 +0200
@@ -125,6 +125,8 @@
class ProtectedObjectSecurityPolicyEditForm(AdminDialogEditForm):
"""Protected object security policy edit form"""
+ prefix = 'security_policy.'
+
legend = _("Update security policy")
icon_css_class = 'fa fa-fw fa-key'
--- a/src/pyams_security/zmi/utility.py Wed Apr 11 11:39:16 2018 +0200
+++ b/src/pyams_security/zmi/utility.py Wed Apr 11 11:40:14 2018 +0200
@@ -32,7 +32,7 @@
from pyams_form.group import NamedWidgetsGroup
from pyams_pagelet.pagelet import pagelet_config
from pyams_security.zmi.widget import OrderedPluginsFieldWidget
-from pyams_skin.container import ContainerView
+from pyams_skin.container import ContainerView, delete_container_element
from pyams_skin.page import DefaultPageHeaderAdapter
from pyams_skin.table import BaseTable, DefaultElementEditorAdapter, ActionColumn, I18nColumn, TrashColumn
from pyams_skin.viewlet.menu import MenuItem
@@ -89,12 +89,9 @@
def data_attributes(self):
manager = query_utility(ISecurityManager)
attributes = super(SecurityManagerPluginsTable, self).data_attributes
- table_attrs = {'data-ams-location': absolute_url(manager, self.request),
- 'data-ams-delete-target': 'delete-plugin.json'}
- if 'table' in attributes:
- attributes['table'].update(table_attrs)
- else:
- attributes['table'] = table_attrs
+ attributes.setdefault('table', {}).update({
+ 'data-ams-location': absolute_url(manager, self.request)
+ })
return attributes
@@ -133,6 +130,13 @@
checker = lambda col, x: x.prefix != SYSTEM_PREFIX
+@view_config(name='delete-element.json', context=ISecurityManager, request_type=IPyAMSLayer,
+ permission=MANAGE_SECURITY_PERMISSION, renderer='json', xhr=True)
+def delete_security_manager_plugin(request):
+ """Delete plug-in from security manager"""
+ return delete_container_element(request, ignore_permission=True)
+
+
@adapter_config(context=(ISite, IAdminLayer, SecurityManagerPluginsTable), provides=IValues)
class SecurityManagerValuesAdapter(ContextRequestViewAdapter):
"""Security manager values adapter"""
@@ -180,6 +184,8 @@
class SecurityManagerEditForm(AdminDialogEditForm):
"""Security manager edit form"""
+ prefix = 'security_properties.'
+
title = _("System security manager")
legend = _("Security manager properties")
icon_css_class = 'fa fa-fw fa-lock'
@@ -230,21 +236,3 @@
permission=MANAGE_SECURITY_PERMISSION, renderer='json', xhr=True)
class SecurityManagerAJAXEditForm(AJAXEditForm, SecurityManagerEditForm):
"""Security manager edit form, AJAX view"""
-
-
-@view_config(name='delete-plugin.json', context=ISecurityManager, request_type=IPyAMSLayer,
- permission=MANAGE_SECURITY_PERMISSION, renderer='json', xhr=True)
-def delete_security_manager_plugin(request):
- """Delete plug-in from security manager"""
- 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'}