Mercurial > libervia-web
comparison browser_side/radiocol.py @ 127:e19a8de8b3de
radio collective first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 22 Jan 2012 19:38:05 +0100 |
parents | |
children | 2849ec993d89 |
comparison
equal
deleted
inserted
replaced
126:adecb2566b53 | 127:e19a8de8b3de |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 Libervia: a Salut à Toi frontend | |
6 Copyright (C) 2011 Jérôme Poisson <goffi@goffi.org> | |
7 | |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Affero General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
22 import pyjd # this is dummy in pyjs | |
23 from pyjamas.ui.VerticalPanel import VerticalPanel | |
24 from pyjamas.ui.HorizontalPanel import HorizontalPanel | |
25 from pyjamas.ui.SimplePanel import SimplePanel | |
26 from pyjamas.ui.FormPanel import FormPanel | |
27 from pyjamas.ui.DockPanel import DockPanel | |
28 from pyjamas.ui.NamedFrame import NamedFrame | |
29 from pyjamas.ui.FileUpload import FileUpload | |
30 from pyjamas.ui.Label import Label | |
31 from pyjamas.ui.Button import Button | |
32 from pyjamas.ui.ClickListener import ClickHandler | |
33 from pyjamas.ui.MouseListener import MouseHandler | |
34 from pyjamas import Window | |
35 | |
36 from jid import JID | |
37 from tools import html_sanitize | |
38 | |
39 | |
40 class MetadataPanel(VerticalPanel): | |
41 | |
42 def __init__(self): | |
43 VerticalPanel.__init__(self) | |
44 self.artist = Label("artist:") | |
45 self.album = Label("album:") | |
46 self.title = Label("title:") | |
47 self.add(self.artist) | |
48 self.add(self.album) | |
49 self.add(self.title) | |
50 | |
51 class ControlPanel(FormPanel): | |
52 """Panel used to show controls to add a song, or vote for the current one""" | |
53 | |
54 def __init__(self): | |
55 FormPanel.__init__(self) | |
56 self.setEncoding(FormPanel.ENCODING_MULTIPART) | |
57 self.setMethod(FormPanel.METHOD_POST) | |
58 self.setAction("upload") # set this as appropriate | |
59 #self.setTarget("results") | |
60 vPanel = VerticalPanel() | |
61 | |
62 hPanel = HorizontalPanel() | |
63 hPanel.setSpacing(5) | |
64 self.field = FileUpload() | |
65 self.field.setName("song") | |
66 hPanel.add(self.field) | |
67 | |
68 hPanel.add(Button("Upload song", getattr(self, "onBtnClick"))) | |
69 | |
70 vPanel.add(hPanel) | |
71 | |
72 results = NamedFrame("results") | |
73 vPanel.add(results) | |
74 | |
75 self.add(vPanel) | |
76 self.addFormHandler(self) | |
77 | |
78 def onBtnClick(self): | |
79 self.submit() | |
80 | |
81 def onSubmit(self, event): | |
82 pass | |
83 | |
84 def onSubmitComplete(self, event): | |
85 result = event.getResults() | |
86 if result == "OK": | |
87 Window.alert('Your song has been added to queue') | |
88 elif result == "KO": | |
89 Window.alert('Something went wrong during your song upload') | |
90 else: | |
91 Window.alert('Submit error: %s' % result) | |
92 | |
93 class RadioColPanel(HorizontalPanel, ClickHandler): | |
94 | |
95 def __init__(self, parent, referee, player_nick): | |
96 HorizontalPanel.__init__(self) | |
97 ClickHandler.__init__(self) | |
98 self._parent = parent | |
99 self.referee = referee | |
100 self.setStyleName("radiocolPanel") | |
101 | |
102 # Now we set up the layout | |
103 self.left_panel = VerticalPanel() | |
104 self.add(self.left_panel) | |
105 self.right_panel = DockPanel() | |
106 self.metadata_panel = MetadataPanel() | |
107 self.right_panel.add(self.metadata_panel, DockPanel.CENTER) | |
108 self.control_panel = ControlPanel() | |
109 self.right_panel.add(self.control_panel, DockPanel.SOUTH) | |
110 self.add(self.right_panel) | |
111 self.right_panel.setBorderWidth(1) | |
112 self.left_panel.add(Label("Musique 1")) | |
113 self.left_panel.add(Label("Musique 2")) | |
114 self.left_panel.add(Label("Musique 3")) | |
115 self.left_panel.add(Label("Musique 4")) | |
116 self.left_panel.add(Label("Musique 5")) | |
117 | |
118 | |
119 self.addClickListener(self) | |
120 |