diff browser_side/menu.py @ 283:0eba1c4f9c6f

browser_side (plugins radiocol, xep-0054): check for file size or type before uploading
author souliane <souliane@mailoo.org>
date Mon, 25 Nov 2013 20:39:28 +0100
parents 0cb9869b42b6
children 7316a5696366
line wrap: on
line diff
--- a/browser_side/menu.py	Tue Dec 10 09:07:03 2013 +0100
+++ b/browser_side/menu.py	Mon Nov 25 20:39:28 2013 +0100
@@ -37,6 +37,7 @@
 from pyjamas import Window
 from jid import JID
 from tools import html_sanitize
+from tools import FilterFileUpload
 from xmlui import XMLUI
 import panels
 import dialog
@@ -86,8 +87,7 @@
 
         hPanel = HorizontalPanel()
         hPanel.setSpacing(5)
-        self.file_upload = FileUpload()
-        self.file_upload.setName("avatar_path")
+        self.file_upload = FilterFileUpload("avatar_path", 2)
         self.vPanel.add(self.file_upload)
 
         hPanel.add(Button("Cancel", getattr(self, "onCloseBtnClick")))
@@ -112,6 +112,8 @@
             print ("WARNING: no close method defined")
 
     def onSubmitBtnClick(self):
+        if not self.file_upload.check():
+            return
         self.message.setHTML('<strong>Submitting, please wait...</strong>')
         self.upload_btn.setEnabled(False)
         self.submit()