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