Mercurial > libervia-web
comparison browser_side/radiocol.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 | a763b2ac5d41 |
children | bee4719af9b9 |
comparison
equal
deleted
inserted
replaced
282:ae3ec654836d | 283:0eba1c4f9c6f |
---|---|
24 from pyjamas.ui.HorizontalPanel import HorizontalPanel | 24 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
25 from pyjamas.ui.SimplePanel import SimplePanel | 25 from pyjamas.ui.SimplePanel import SimplePanel |
26 from pyjamas.ui.FlexTable import FlexTable | 26 from pyjamas.ui.FlexTable import FlexTable |
27 from pyjamas.ui.FormPanel import FormPanel | 27 from pyjamas.ui.FormPanel import FormPanel |
28 from pyjamas.ui.NamedFrame import NamedFrame | 28 from pyjamas.ui.NamedFrame import NamedFrame |
29 from pyjamas.ui.FileUpload import FileUpload | |
30 from pyjamas.ui.Label import Label | 29 from pyjamas.ui.Label import Label |
31 from pyjamas.ui.Button import Button | 30 from pyjamas.ui.Button import Button |
32 from pyjamas.ui.ClickListener import ClickHandler | 31 from pyjamas.ui.ClickListener import ClickHandler |
33 from pyjamas.ui.MouseListener import MouseHandler | 32 from pyjamas.ui.MouseListener import MouseHandler |
34 from pyjamas.ui.Hidden import Hidden | 33 from pyjamas.ui.Hidden import Hidden |
37 from pyjamas.Timer import Timer | 36 from pyjamas.Timer import Timer |
38 from __pyjamas__ import JS | 37 from __pyjamas__ import JS |
39 | 38 |
40 from jid import JID | 39 from jid import JID |
41 from tools import html_sanitize | 40 from tools import html_sanitize |
41 from tools import FilterFileUpload | |
42 | 42 |
43 | 43 |
44 class MetadataPanel(FlexTable): | 44 class MetadataPanel(FlexTable): |
45 | 45 |
46 def __init__(self): | 46 def __init__(self): |
86 self.setAction("upload_radiocol") | 86 self.setAction("upload_radiocol") |
87 vPanel = VerticalPanel() | 87 vPanel = VerticalPanel() |
88 | 88 |
89 hPanel = HorizontalPanel() | 89 hPanel = HorizontalPanel() |
90 hPanel.setSpacing(5) | 90 hPanel.setSpacing(5) |
91 self.file_upload = FileUpload() | 91 types = [('audio/ogg', '*.ogg', 'Ogg Vorbis Audio'), |
92 self.file_upload.setName("song") | 92 ('video/ogg', '*.ogv', 'Ogg Vorbis Video'), |
93 ('application/ogg', '*.ogx', 'Ogg Vorbis Multiplex')] | |
94 self.file_upload = FilterFileUpload("song", 5, types) | |
93 hPanel.add(self.file_upload) | 95 hPanel.add(self.file_upload) |
94 | 96 |
95 self.upload_btn = Button("Upload song", getattr(self, "onBtnClick")) | 97 self.upload_btn = Button("Upload song", getattr(self, "onBtnClick")) |
96 hPanel.add(self.upload_btn) | 98 hPanel.add(self.upload_btn) |
97 | 99 |
109 | 111 |
110 def _timeCb(self, timer): | 112 def _timeCb(self, timer): |
111 self.status.setText('') | 113 self.status.setText('') |
112 | 114 |
113 def onBtnClick(self): | 115 def onBtnClick(self): |
114 self.submit() | 116 if self.file_upload.check(): |
117 self.submit() | |
118 self.file_upload.setFilename("") | |
119 self.status.setText('[Submitting, please wait...]') | |
115 | 120 |
116 def onSubmit(self, event): | 121 def onSubmit(self, event): |
117 pass | 122 pass |
118 | 123 |
119 def blockUpload(self): | 124 def blockUpload(self): |
131 self.status.setStyleName('radiocol_upload_status_ok') | 136 self.status.setStyleName('radiocol_upload_status_ok') |
132 self._timer.schedule(5000) | 137 self._timer.schedule(5000) |
133 elif result == "KO": | 138 elif result == "KO": |
134 self.status.setText('[Something went wrong during your song upload]') | 139 self.status.setText('[Something went wrong during your song upload]') |
135 self.status.setStyleName('radiocol_upload_status_ko') | 140 self.status.setStyleName('radiocol_upload_status_ko') |
141 self._timer.schedule(5000) | |
136 else: | 142 else: |
137 Window.alert('Submit error: %s' % result) | 143 Window.alert('Submit error: %s' % result) |
144 self.status.setText('') | |
138 | 145 |
139 | 146 |
140 class Player(HTML): | 147 class Player(HTML): |
141 | 148 |
142 def __init__(self, player_id, metadata_panel): | 149 def __init__(self, player_id, metadata_panel): |