src/pyams_security/zmi/plugin/group.py
changeset 8 67acb59f115e
parent 2 94e76f8e9828
child 17 fb914030a05b
--- a/src/pyams_security/zmi/plugin/group.py	Sat Feb 28 15:25:05 2015 +0100
+++ b/src/pyams_security/zmi/plugin/group.py	Sat Feb 28 15:26:27 2015 +0100
@@ -89,6 +89,15 @@
         return absolute_url(self.context, self.request, 'security-manager.html')
 
 
+@subscriber(IDataExtractedEvent, form_selector=GroupsFolderAddForm)
+def handle_new_user_folder_data_extraction(event):
+    """Handle new groups folder plug-in form data extraction"""
+    manager = query_utility(ISecurityManager)
+    prefix = event.data.get('prefix')
+    if prefix in manager:
+        event.form.widgets.errors += (Invalid(_("Specified prefix is already used!")),)
+
+
 @view_config(name='add-groups-folder.json', context=ISite, request_type=IPyAMSLayer,
              permission='system.manage', renderer='json', xhr=True)
 class GroupsFolderAJAXAddForm(AJAXAddForm, GroupsFolderAddForm):