annotate browser_side/register.py @ 407:6a6551de4414

browser_side: display chat states (with symbols) for MUC participants
author souliane <souliane@mailoo.org>
date Sun, 16 Mar 2014 21:03:50 +0100
parents 06fbe6055925
children 20c508f9b32a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
6 # Copyright (C) 2011, 2012 Adrien Vigneron <adrienvigneron@mailoo.org>
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
7
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
8 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
11 # (at your option) any later version.
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
12
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
13 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
16 # GNU Affero General Public License for more details.
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
17
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 249
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
20
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
21 #This page manage subscription and new account creation
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import pyjd # this is dummy in pyjs
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
23
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
24 from pyjamas.ui.SimplePanel import SimplePanel
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.VerticalPanel import VerticalPanel
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
26 from pyjamas.ui.HorizontalPanel import HorizontalPanel
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
27 from pyjamas.ui.TabPanel import TabPanel
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
28 from pyjamas.ui.TabBar import TabBar
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.PasswordTextBox import PasswordTextBox
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.TextBox import TextBox
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.FormPanel import FormPanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.Button import Button
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
33 from pyjamas.ui.Label import Label
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
34 from pyjamas.ui.PopupPanel import PopupPanel
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
35 from pyjamas.ui.Image import Image
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
36 from pyjamas.ui.Hidden import Hidden
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from pyjamas import Window
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
38 from pyjamas.ui.KeyboardListener import KEY_ESCAPE, KEY_ENTER
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
39 import re
237
531b8809d1ab browser_side: fixed browser built-in auto-completion in login/register panels
souliane <souliane@mailoo.org>
parents: 222
diff changeset
40 from pyjamas.Timer import Timer
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
41
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
42
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
43 class RegisterPanel(FormPanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
44
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
45 def __init__(self, callback):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
46 """
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
47 @param callback: method to call if login successful
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
48 """
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
49 FormPanel.__init__(self)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
50 self.setSize('600px', '350px')
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self.callback = callback
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
52 self.setMethod(FormPanel.METHOD_POST)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
53 main_panel = HorizontalPanel()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
54 main_panel.setStyleName('registerPanel_main')
77
975e6be24e11 media paths update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
55 left_side = Image("media/libervia/register_left.png")
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
56 main_panel.add(left_side)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
57
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
58 ##TabPanel##
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
59 tab_bar = TabBar()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
60 tab_bar.setStyleName('registerPanel_tabs')
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
61 self.right_side = TabPanel(tab_bar)
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
62 self.right_side.setStyleName('registerPanel_right_side')
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
63 main_panel.add(self.right_side)
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
64 main_panel.setCellWidth(self.right_side, '100%')
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
65
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
66 ##Login tab##
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
67 login_tab = SimplePanel()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
68 login_tab.setStyleName('registerPanel_content')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
69 login_vpanel = VerticalPanel()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
70 login_tab.setWidget(login_vpanel)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
71
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
72 self.login_warning_msg = Label('')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
73 self.login_warning_msg.setVisible(False)
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
74 self.login_warning_msg.setStyleName('formWarning')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
75 login_vpanel.add(self.login_warning_msg)
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
76
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
77 login_label = Label('Login:')
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
78 self.login_box = TextBox()
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
79 self.login_box.setName("login")
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
80 self.login_box.addKeyboardListener(self)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
81 login_pass_label = Label('Password:')
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
82 self.login_pass_box = PasswordTextBox()
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
83 self.login_pass_box.setName("login_password")
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
84 self.login_pass_box.addKeyboardListener(self)
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
85
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
86 login_vpanel.add(login_label)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
87 login_vpanel.add(self.login_box)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
88 login_vpanel.add(login_pass_label)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
89 login_vpanel.add(self.login_pass_box)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
90 login_but = Button("Log in", getattr(self, "onLogin"))
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
91 login_but.setStyleName('button')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
92 login_but.addStyleName('red')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
93 login_vpanel.add(login_but)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
94
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
95 #The hidden submit_type field
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
96 self.submit_type = Hidden('submit_type')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
97 login_vpanel.add(self.submit_type)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
98
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
99 ##Register tab##
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
100 register_tab = SimplePanel()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
101 register_tab.setStyleName('registerPanel_content')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
102 register_vpanel = VerticalPanel()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
103 register_tab.setWidget(register_vpanel)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
104
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
105 self.register_warning_msg = Label('')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
106 self.register_warning_msg.setVisible(False)
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
107 self.register_warning_msg.setStyleName('formWarning')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
108 register_vpanel.add(self.register_warning_msg)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
109
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
110 register_login_label = Label('Login:')
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
111 self.register_login_box = TextBox()
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
112 self.register_login_box.setName("register_login")
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
113 self.register_login_box.addKeyboardListener(self)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
114 email_label = Label('E-mail:')
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
115 self.email_box = TextBox()
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
116 self.email_box.setName("email")
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
117 self.email_box.addKeyboardListener(self)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
118 register_pass_label = Label('Password:')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
119 self.register_pass_box = PasswordTextBox()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
120 self.register_pass_box.setName("register_password")
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
121 self.register_pass_box.addKeyboardListener(self)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
122 register_vpanel.add(register_login_label)
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
123 register_vpanel.add(self.register_login_box)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
124 register_vpanel.add(email_label)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
125 register_vpanel.add(self.email_box)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
126 register_vpanel.add(register_pass_label)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
127 register_vpanel.add(self.register_pass_box)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
128
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
129 register_but = Button("Register", getattr(self, "onRegister"))
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
130 register_but.setStyleName('button')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
131 register_but.addStyleName('red')
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
132 register_vpanel.add(register_but)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
133
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
134 self.right_side.add(login_tab, 'Login')
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
135 self.right_side.add(register_tab, 'Register')
222
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
136 self.right_side.addTabListener(self)
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
137 self.right_side.selectTab(0)
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
138 login_tab.setWidth(None)
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
139 register_tab.setWidth(None)
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
140
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
141 self.add(main_panel)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
142 self.addFormHandler(self)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
143 self.setAction('register_api/login')
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
144
222
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
145 def onBeforeTabSelected(self, sender, tabIndex):
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
146 return True
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
147
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
148 def onTabSelected(self, sender, tabIndex):
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
149 if tabIndex == 0:
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
150 self.login_box.setFocus(True)
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
151 elif tabIndex == 1:
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
152 self.register_login_box.setFocus(True)
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
153
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
154 def onKeyPress(self, sender, keycode, modifiers):
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
155 if keycode == KEY_ENTER:
237
531b8809d1ab browser_side: fixed browser built-in auto-completion in login/register panels
souliane <souliane@mailoo.org>
parents: 222
diff changeset
156 # Browsers offer an auto-completion feature to any
531b8809d1ab browser_side: fixed browser built-in auto-completion in login/register panels
souliane <souliane@mailoo.org>
parents: 222
diff changeset
157 # text box, but the selected value is not set when
531b8809d1ab browser_side: fixed browser built-in auto-completion in login/register panels
souliane <souliane@mailoo.org>
parents: 222
diff changeset
158 # the widget looses the focus. Using a timer with
531b8809d1ab browser_side: fixed browser built-in auto-completion in login/register panels
souliane <souliane@mailoo.org>
parents: 222
diff changeset
159 # any delay value > 0 would do the trick.
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
160 if sender == self.login_box:
249
c24715dcd2f6 browser_side: set the "workaround" timers to 5 ms instead of 10:
souliane <souliane@mailoo.org>
parents: 237
diff changeset
161 Timer(5, lambda: self.login_pass_box.setFocus(True))
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
162 elif sender == self.login_pass_box:
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
163 self.onLogin(None)
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
164 elif sender == self.register_login_box:
249
c24715dcd2f6 browser_side: set the "workaround" timers to 5 ms instead of 10:
souliane <souliane@mailoo.org>
parents: 237
diff changeset
165 Timer(5, lambda: self.email_box.setFocus(True))
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
166 elif sender == self.email_box:
249
c24715dcd2f6 browser_side: set the "workaround" timers to 5 ms instead of 10:
souliane <souliane@mailoo.org>
parents: 237
diff changeset
167 Timer(5, lambda: self.register_pass_box.setFocus(True))
216
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
168 elif sender == self.register_pass_box:
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
169 self.onRegister(None)
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
170
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
171 def onKeyUp(self, sender, keycode, modifiers):
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
172 pass
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
173
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
174 def onKeyDown(self, sender, keycode, modifiers):
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
175 pass
9827cda1a6b0 browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents: 173
diff changeset
176
62
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 46
diff changeset
177 def onLogin(self, button):
173
3d998119237e browser side: added login characters check in login panel (similar to the one in register panel)
Goffi <goffi@goffi.org>
parents: 165
diff changeset
178 if not re.match(r'^[a-z0-9_-]+$',self.login_box.getText(), re.IGNORECASE):
3d998119237e browser side: added login characters check in login panel (similar to the one in register panel)
Goffi <goffi@goffi.org>
parents: 165
diff changeset
179 self.login_warning_msg.setText('Invalid login, valid characters are a-z A-Z 0-9 _ -')
3d998119237e browser side: added login characters check in login panel (similar to the one in register panel)
Goffi <goffi@goffi.org>
parents: 165
diff changeset
180 self.login_warning_msg.setVisible(True)
3d998119237e browser side: added login characters check in login panel (similar to the one in register panel)
Goffi <goffi@goffi.org>
parents: 165
diff changeset
181 else:
3d998119237e browser side: added login characters check in login panel (similar to the one in register panel)
Goffi <goffi@goffi.org>
parents: 165
diff changeset
182 self.submit_type.setValue('login')
3d998119237e browser side: added login characters check in login panel (similar to the one in register panel)
Goffi <goffi@goffi.org>
parents: 165
diff changeset
183 self.submit()
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
184
62
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 46
diff changeset
185 def onRegister(self, button):
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
186 if not re.match(r'^[a-z0-9_-]+$',self.register_login_box.getText(), re.IGNORECASE):
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
187 self.register_warning_msg.setText('Invalid login, valid characters are a-z A-Z 0-9 _ -')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
188 self.register_warning_msg.setVisible(True)
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
189 elif not re.match(r'^.+@.+\..+', self.email_box.getText(), re.IGNORECASE):
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
190 self.register_warning_msg.setText('Invalid email address')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
191 self.register_warning_msg.setVisible(True)
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
192 else:
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
193 self.register_warning_msg.setVisible(False)
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
194 self.submit_type.setValue('register')
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
195 self.submit()
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
196
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
197 def onSubmit(self, event):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
198 pass
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
199
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
200 def onSubmitComplete(self, event):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
201 result = event.getResults()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
202 if result == "AUTH ERROR":
121
2d40b0f5fb37 server side: asynchronous login
Goffi <goffi@goffi.org>
parents: 77
diff changeset
203 Window.alert('Your login and/or password is incorrect. Please try again')
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
204 elif result == "LOGGED":
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
205 self.callback()
62
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 46
diff changeset
206 elif result == "SESSION_ACTIVE":
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
207 Window.alert('Session already active, this should not happen, please contact the author to fix it')
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
208 elif result == "ALREADY EXISTS":
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
209 self.register_warning_msg.setText('This login already exists, please choose an other one')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
210 self.register_warning_msg.setVisible(True)
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
211 elif result == "INTERNAL":
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
212 self.register_warning_msg.setText('SERVER ERROR: something went wrong during registration process, please contact the server administrator')
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
213 self.register_warning_msg.setVisible(True)
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
214 elif result == "REGISTRATION":
161
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
215 self.login_warning_msg.setVisible(False)
03ac7f51a35b browser side: fixed registration:
Goffi <goffi@goffi.org>
parents: 131
diff changeset
216 self.register_warning_msg.setVisible(False)
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
217 self.login_box.setText(self.register_login_box.getText())
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
218 self.register_login_box.setText('')
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
219 self.register_pass_box.setText('')
67
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
220 self.email_box.setText('')
b096facaa5b3 registration fix
Goffi <goffi@goffi.org>
parents: 66
diff changeset
221 self.right_side.selectTab(0)
382
06fbe6055925 browser_side: focus the password input after account creation
souliane <souliane@mailoo.org>
parents: 340
diff changeset
222 self.login_pass_box.setFocus(True)
46
c3ee630914ba Account creation
Goffi <goffi@goffi.org>
parents: 43
diff changeset
223 Window.alert('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO')
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
224 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
225 Window.alert('Submit error: %s' % result)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
226
222
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
227
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
228 class RegisterBox(PopupPanel):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
229
222
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
230 def __init__(self, callback, *args, **kwargs):
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
231 PopupPanel.__init__(self, *args, **kwargs)
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
232 self._form = RegisterPanel(callback)
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
233 self.setWidget(self._form)
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
234
66
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
235 def onWindowResized(self, width, height):
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
236 super(RegisterBox, self).onWindowResized(width, height)
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
237 self.centerBox()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
238
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
239 def show(self):
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
240 super(RegisterBox, self).show()
9d8e79ac4c9c Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents: 62
diff changeset
241 self.centerBox()
222
759fd7386e1e browser_side: set the focus to the first field when a tab is selected from the register panel
souliane <souliane@mailoo.org>
parents: 216
diff changeset
242 self._form.login_box.setFocus(True)