diff browser_side/dialog.py @ 211:49920d76aa6a

browser side: added a mechanism to define forbidden patterns during new contact group creation this could serve for "Bug 32 - Check group names before adding them (edit)" but not used yet fix bug 32
author souliane <souliane@mailoo.org>
date Fri, 06 Sep 2013 15:51:40 +0200
parents 3092f6b1710c
children a05e16f4a343
line wrap: on
line diff
--- a/browser_side/dialog.py	Fri Sep 06 15:40:33 2013 +0200
+++ b/browser_side/dialog.py	Fri Sep 06 15:51:40 2013 +0200
@@ -33,6 +33,10 @@
 from pyjamas.ui.KeyboardListener import KEY_ESCAPE, KEY_ENTER
 from pyjamas.ui.MouseListener import MouseWheelHandler
 from pyjamas import DOM
+from pyjamas import Window
+
+# List here the patterns that are not allowed in contact group names
+FORBIDDEN_PATTERNS_IN_GROUP = ()
 
 class ContactsChooser(DialogBox):
 
@@ -248,7 +252,7 @@
 
     def setGroupsSelected(self, selected_groups):
         self.list_box.setItemTextSelection(selected_groups)
-    
+
     def onOK(self, sender):
         self.hide()
         if self.ok_cb:
@@ -260,7 +264,12 @@
             self.cancel_cb(self)
 
     def onGroupInput(self, sender):
-        self.list_box.addItem(sender.getText())
+        text = sender.getText()
+        for pattern in FORBIDDEN_PATTERNS_IN_GROUP:
+            if pattern in text:
+                Window.alert("The pattern '%s' is not allowed in group names." % pattern)
+                return
+        self.list_box.addItem(text)
         sender.setText('')
         self.list_box.setItemSelected(self.list_box.getItemCount()-1, "selected")