Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
282:ae3ec654836d | 283:0eba1c4f9c6f |
---|---|
35 from pyjamas.ui.HTML import HTML | 35 from pyjamas.ui.HTML import HTML |
36 from pyjamas.ui.Frame import Frame | 36 from pyjamas.ui.Frame import Frame |
37 from pyjamas import Window | 37 from pyjamas import Window |
38 from jid import JID | 38 from jid import JID |
39 from tools import html_sanitize | 39 from tools import html_sanitize |
40 from tools import FilterFileUpload | |
40 from xmlui import XMLUI | 41 from xmlui import XMLUI |
41 import panels | 42 import panels |
42 import dialog | 43 import dialog |
43 from contact_group import ContactGroupEditor | 44 from contact_group import ContactGroupEditor |
44 import re | 45 import re |
84 self.message = HTML('Please select an image to show as your avatar...<br>Your picture must be a square and will be resized to 64x64 pixels if necessary') | 85 self.message = HTML('Please select an image to show as your avatar...<br>Your picture must be a square and will be resized to 64x64 pixels if necessary') |
85 self.vPanel.add(self.message) | 86 self.vPanel.add(self.message) |
86 | 87 |
87 hPanel = HorizontalPanel() | 88 hPanel = HorizontalPanel() |
88 hPanel.setSpacing(5) | 89 hPanel.setSpacing(5) |
89 self.file_upload = FileUpload() | 90 self.file_upload = FilterFileUpload("avatar_path", 2) |
90 self.file_upload.setName("avatar_path") | |
91 self.vPanel.add(self.file_upload) | 91 self.vPanel.add(self.file_upload) |
92 | 92 |
93 hPanel.add(Button("Cancel", getattr(self, "onCloseBtnClick"))) | 93 hPanel.add(Button("Cancel", getattr(self, "onCloseBtnClick"))) |
94 self.upload_btn = Button("Upload avatar", getattr(self, "onSubmitBtnClick")) | 94 self.upload_btn = Button("Upload avatar", getattr(self, "onSubmitBtnClick")) |
95 hPanel.add(self.upload_btn) | 95 hPanel.add(self.upload_btn) |
110 self.close_cb() | 110 self.close_cb() |
111 else: | 111 else: |
112 print ("WARNING: no close method defined") | 112 print ("WARNING: no close method defined") |
113 | 113 |
114 def onSubmitBtnClick(self): | 114 def onSubmitBtnClick(self): |
115 if not self.file_upload.check(): | |
116 return | |
115 self.message.setHTML('<strong>Submitting, please wait...</strong>') | 117 self.message.setHTML('<strong>Submitting, please wait...</strong>') |
116 self.upload_btn.setEnabled(False) | 118 self.upload_btn.setEnabled(False) |
117 self.submit() | 119 self.submit() |
118 | 120 |
119 def onSubmit(self, event): | 121 def onSubmit(self, event): |