Mercurial > libervia-web
annotate src/browser/sat_browser/register.py @ 736:fe3c2357a8c9
fixes/improve ListManager and contact group manager + better PEP-8 compliance
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 19 Nov 2015 11:41:03 +0100 |
parents | 273b39f04d8e |
children | 8ac862f6e5b3 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
249
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
685 | 5 # Copyright (C) 2011, 2012, 2013, 2014, 2015 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 | 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 | 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 | 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 | 20 |
21 #This page manage subscription and new account creation | |
22 | |
451 | 23 import pyjd # this is dummy in pyjs |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
24 from sat.core.i18n import _ |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
445
diff
changeset
|
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 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
29 from pyjamas.ui.StackPanel import StackPanel |
0 | 30 from pyjamas.ui.PasswordTextBox import PasswordTextBox |
31 from pyjamas.ui.TextBox import TextBox | |
32 from pyjamas.ui.FormPanel import FormPanel | |
33 from pyjamas.ui.Button import Button | |
46 | 34 from pyjamas.ui.Label import Label |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
35 from pyjamas.ui.HTML import HTML |
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 |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
382
diff
changeset
|
40 from pyjamas.ui.KeyboardListener import KEY_ENTER |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
445
diff
changeset
|
41 from pyjamas.Timer import Timer |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
445
diff
changeset
|
42 |
46 | 43 import re |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
445
diff
changeset
|
44 |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
445
diff
changeset
|
45 from constants import Const as C |
0 | 46 |
47 | |
48 class RegisterPanel(FormPanel): | |
49 | |
50 def __init__(self, callback): | |
51 """ | |
52 @param callback: method to call if login successful | |
53 """ | |
54 FormPanel.__init__(self) | |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
55 self.setSize('600px', '350px') |
0 | 56 self.callback = callback |
57 self.setMethod(FormPanel.METHOD_POST) | |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
58 main_panel = HorizontalPanel() |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
59 main_panel.setStyleName('registerPanel_main') |
77 | 60 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
|
61 main_panel.add(left_side) |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
62 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
63 ##StackPanel## |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
64 self.right_side = StackPanel(StyleName='registerPanel_right_side') |
67 | 65 main_panel.add(self.right_side) |
66 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
|
67 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
68 ##Login stack## |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
69 login_stack = SimplePanel() |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
70 login_stack.setStyleName('registerPanel_content') |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
71 login_vpanel = VerticalPanel() |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
72 login_stack.setWidget(login_vpanel) |
216
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
73 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
74 self.login_warning_msg = HTML('') |
161 | 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 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
100 ##Register stack## |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
101 register_stack = SimplePanel() |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
102 register_stack.setStyleName('registerPanel_content') |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
103 register_vpanel = VerticalPanel() |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
104 register_stack.setWidget(register_vpanel) |
216
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
105 |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
106 self.register_warning_msg = HTML('') |
161 | 107 self.register_warning_msg.setStyleName('formWarning') |
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 | 111 self.register_login_box = TextBox() |
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 | 115 self.email_box = TextBox() |
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 | 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 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
129 register_but = Button("Register a new account", getattr(self, "onRegister")) |
66
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 |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
134 self.right_side.add(login_stack, 'Return to the login screen') |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
135 self.right_side.add(register_stack, 'No account yet? Create a new one!') |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
136 self.right_side.addStackChangeListener(self) |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
137 login_stack.setWidth(None) |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
138 register_stack.setWidth(None) |
216
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
139 |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
140 self.add(main_panel) |
0 | 141 self.addFormHandler(self) |
142 self.setAction('register_api/login') | |
143 | |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
144 def onStackChanged(self, sender, index): |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
145 if index == 0: |
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 self.login_box.setFocus(True) |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
147 elif index == 1: |
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
|
148 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
|
149 |
216
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
150 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
|
151 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
|
152 # 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
|
153 # 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
|
154 # 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
|
155 # 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
|
156 if sender == self.login_box: |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
382
diff
changeset
|
157 Timer(5, lambda timer: 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
|
158 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
|
159 self.onLogin(None) |
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
160 elif sender == self.register_login_box: |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
382
diff
changeset
|
161 Timer(5, lambda timer: 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
|
162 elif sender == self.email_box: |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
382
diff
changeset
|
163 Timer(5, lambda timer: 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
|
164 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
|
165 self.onRegister(None) |
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
166 |
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
167 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
|
168 pass |
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
169 |
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
170 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
|
171 pass |
9827cda1a6b0
browser_side: added key listener to login and register panels
souliane <souliane@mailoo.org>
parents:
173
diff
changeset
|
172 |
62 | 173 def onLogin(self, button): |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
174 if not re.match(r'^[a-z0-9_-]+$', self.login_box.getText(), re.IGNORECASE): |
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 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
|
176 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
|
177 self.submit_type.setValue('login') |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
487
diff
changeset
|
178 self.submit(None) |
46 | 179 |
62 | 180 def onRegister(self, button): |
487
e588335b6aa8
browser and server side: force lower case for the profile name at new account creation + fixes CSS for textarea
souliane <souliane@mailoo.org>
parents:
481
diff
changeset
|
181 # XXX: for now libervia forces the creation to lower case |
e588335b6aa8
browser and server side: force lower case for the profile name at new account creation + fixes CSS for textarea
souliane <souliane@mailoo.org>
parents:
481
diff
changeset
|
182 self.register_login_box.setText(self.register_login_box.getText().lower()) |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
183 if not re.match(r'^[a-z0-9_-]+$', self.register_login_box.getText(), re.IGNORECASE): |
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
184 self.register_warning_msg.setHTML(_('Invalid login, valid characters<br>are a-z A-Z 0-9 _ -')) |
46 | 185 elif not re.match(r'^.+@.+\..+', self.email_box.getText(), re.IGNORECASE): |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
186 self.register_warning_msg.setHTML(_('Invalid email address')) |
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
187 elif len(self.register_pass_box.getText()) < C.PASSWORD_MIN_LENGTH: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
188 self.register_warning_msg.setHTML(_('Your password must contain<br>at least %d characters.') % C.PASSWORD_MIN_LENGTH) |
46 | 189 else: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
190 self.register_warning_msg.setHTML("") |
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') |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
487
diff
changeset
|
192 self.submit(None) |
46 | 193 |
0 | 194 def onSubmit(self, event): |
195 pass | |
196 | |
197 def onSubmitComplete(self, event): | |
198 result = event.getResults() | |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
199 if result == C.PROFILE_AUTH_ERROR: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
200 self.login_warning_msg.setHTML(_('Your login and/or password is incorrect. Please try again.')) |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
201 elif result == C.XMPP_AUTH_ERROR: |
464
bea9788f3170
browser and server sides: don't handle the "connectionError" signal anymore, we now use asyncConnect errback:
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
202 # TODO: call stdui action CHANGE_XMPP_PASSWD_ID as it's done in primitivus |
bea9788f3170
browser and server sides: don't handle the "connectionError" signal anymore, we now use asyncConnect errback:
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
203 Window.alert(_(u'Your SàT profile has been authenticated but the associated XMPP account failed to connect. Please use another SàT frontend to set another XMPP password.')) |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
204 elif result == C.PROFILE_LOGGED: |
0 | 205 self.callback() |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
206 elif result == C.SESSION_ACTIVE: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
207 Window.alert(_('Session already active, this should not happen, please contact the author to fix it.')) |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
208 elif result == C.NO_REPLY: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
209 Window.alert(_("Did not receive a reply (the timeout expired or the connection is broken).")) |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
210 elif result == C.ALREADY_EXISTS: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
211 self.register_warning_msg.setHTML(_('This login already exists,<br>please choose another one.')) |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
212 elif result == C.INTERNAL_ERROR: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
213 self.register_warning_msg.setHTML(_('An registration error occurred, please contact the server administrator.')) |
481
bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
214 elif result == C.REGISTRATION_SUCCEED: |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
215 self.login_warning_msg.setHTML("") |
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
216 self.register_warning_msg.setHTML("") |
67 | 217 self.login_box.setText(self.register_login_box.getText()) |
445
c0ff91cabea0
server_side, browser_side: new account password must contain at least 6 chars + cosmetic change for register warning message
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
218 self.login_pass_box.setText('') |
67 | 219 self.register_login_box.setText('') |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
220 self.register_pass_box.setText('') |
67 | 221 self.email_box.setText('') |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
222 self.right_side.showStack(0) |
382
06fbe6055925
browser_side: focus the password input after account creation
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
223 self.login_pass_box.setFocus(True) |
729
273b39f04d8e
browser_side: change login and register panels (makes it more visible and less confusing)
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
224 Window.alert(_('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO.')) |
0 | 225 else: |
464
bea9788f3170
browser and server sides: don't handle the "connectionError" signal anymore, we now use asyncConnect errback:
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
226 Window.alert(_('Submit error: %s' % result)) |
0 | 227 |
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
|
228 |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
229 class RegisterBox(PopupPanel): |
0 | 230 |
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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
236 def onWindowResized(self, width, height): |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
237 super(RegisterBox, self).onWindowResized(width, height) |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
238 self.centerBox() |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
239 |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
240 def show(self): |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
241 super(RegisterBox, self).show() |
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
242 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
|
243 self._form.login_box.setFocus(True) |