comparison browser_side/register.py @ 161:03ac7f51a35b

browser side: fixed registration: - fixed warning messages (there are now 2 warning messages, one for login, one for registration) - fixed login & register tab sizes - added "INTERNAL" error, in case of something going really wrong at server side during account creation - minor typo corrections
author Goffi <goffi@goffi.org>
date Mon, 07 Jan 2013 01:15:19 +0100
parents ddfcc4cb6cee
children 9763dec220ed
comparison
equal deleted inserted replaced
160:6f913f5adca8 161:03ac7f51a35b
72 login_tab.setStyleName('registerPanel_content') 72 login_tab.setStyleName('registerPanel_content')
73 login_vpanel = VerticalPanel() 73 login_vpanel = VerticalPanel()
74 login_tab.setWidget(login_vpanel) 74 login_tab.setWidget(login_vpanel)
75 75
76 76
77 self.warning_msg = Label() 77 self.login_warning_msg = Label('')
78 self.warning_msg.setVisible(False) 78 self.login_warning_msg.setVisible(False)
79 self.warning_msg.setStyleName('formWarning') 79 self.login_warning_msg.setStyleName('formWarning')
80 #login_vpanel.add(self.warning_msg) 80 login_vpanel.add(self.login_warning_msg)
81 81
82 login_label = Label('Login:') 82 login_label = Label('Login:')
83 self.login_box = TextBox() 83 self.login_box = TextBox()
84 self.login_box.setName("login") 84 self.login_box.setName("login")
85 login_pass_label = Label('Password:') 85 login_pass_label = Label('Password:')
102 ##Register tab## 102 ##Register tab##
103 register_tab = SimplePanel() 103 register_tab = SimplePanel()
104 register_tab.setStyleName('registerPanel_content') 104 register_tab.setStyleName('registerPanel_content')
105 register_vpanel = VerticalPanel() 105 register_vpanel = VerticalPanel()
106 register_tab.setWidget(register_vpanel) 106 register_tab.setWidget(register_vpanel)
107
108 self.register_warning_msg = Label('')
109 self.register_warning_msg.setVisible(False)
110 self.register_warning_msg.setStyleName('formWarning')
111 register_vpanel.add(self.register_warning_msg)
107 112
108 register_login_label = Label('Login:') 113 register_login_label = Label('Login:')
109 self.register_login_box = TextBox() 114 self.register_login_box = TextBox()
110 self.register_login_box.setName("register_login") 115 self.register_login_box.setName("register_login")
111 email_label = Label('E-mail:') 116 email_label = Label('E-mail:')
127 register_vpanel.add(register_but) 132 register_vpanel.add(register_but)
128 133
129 self.right_side.add(login_tab, 'Login') 134 self.right_side.add(login_tab, 'Login')
130 self.right_side.add(register_tab, 'Register') 135 self.right_side.add(register_tab, 'Register')
131 self.right_side.selectTab(0) 136 self.right_side.selectTab(0)
137 login_tab.setWidth(None)
138 register_tab.setWidth(None)
132 139
133 self.add(main_panel) 140 self.add(main_panel)
134 self.addFormHandler(self) 141 self.addFormHandler(self)
135 self.setAction('register_api/login') 142 self.setAction('register_api/login')
136 143
138 self.submit_type.setValue('login') 145 self.submit_type.setValue('login')
139 self.submit() 146 self.submit()
140 147
141 def onRegister(self, button): 148 def onRegister(self, button):
142 if not re.match(r'^[a-z0-9_-]+$',self.register_login_box.getText(), re.IGNORECASE): 149 if not re.match(r'^[a-z0-9_-]+$',self.register_login_box.getText(), re.IGNORECASE):
143 self.warning_msg.setText('Invaling login, valid characters are a-z A-Z 0-9 _ -') 150 self.register_warning_msg.setText('Invalid login, valid characters are a-z A-Z 0-9 _ -')
144 self.warning_msg.setVisible(True) 151 self.register_warning_msg.setVisible(True)
145 elif not re.match(r'^.+@.+\..+', self.email_box.getText(), re.IGNORECASE): 152 elif not re.match(r'^.+@.+\..+', self.email_box.getText(), re.IGNORECASE):
146 self.warning_msg.setText('Invaling email address') 153 self.register_warning_msg.setText('Invalid email address')
147 self.warning_msg.setVisible(True) 154 self.register_warning_msg.setVisible(True)
148 else: 155 else:
149 self.warning_msg.setVisible(False) 156 self.register_warning_msg.setVisible(False)
150 self.submit_type.setValue('register') 157 self.submit_type.setValue('register')
151 self.submit() 158 self.submit()
152 159
153 160
154 def onSubmit(self, event): 161 def onSubmit(self, event):
159 if result == "AUTH ERROR": 166 if result == "AUTH ERROR":
160 Window.alert('Your login and/or password is incorrect. Please try again') 167 Window.alert('Your login and/or password is incorrect. Please try again')
161 elif result == "LOGGED": 168 elif result == "LOGGED":
162 self.callback() 169 self.callback()
163 elif result == "SESSION_ACTIVE": 170 elif result == "SESSION_ACTIVE":
164 Window.alert('Session already active, this should not happen, please contact contact the author to fix it') 171 Window.alert('Session already active, this should not happen, please contact the author to fix it')
165 elif result == "ALREADY EXISTS": 172 elif result == "ALREADY EXISTS":
166 self.warning_msg.setText('This login already exists, please choose an other one') 173 self.register_warning_msg.setText('This login already exists, please choose an other one')
167 self.warning_msg.setVisible(True) 174 self.register_warning_msg.setVisible(True)
175 elif result == "INTERNAL":
176 self.register_warning_msg.setText('SERVER ERROR: something went wrong during registration process, please contact the server administrator')
177 self.register_warning_msg.setVisible(True)
168 elif result == "REGISTRATION": 178 elif result == "REGISTRATION":
169 self.warning_msg.setVisible(False) 179 self.login_warning_msg.setVisible(False)
180 self.register_warning_msg.setVisible(False)
170 self.login_box.setText(self.register_login_box.getText()) 181 self.login_box.setText(self.register_login_box.getText())
171 self.register_login_box.setText('') 182 self.register_login_box.setText('')
172 self.register_pass_box.setText('') 183 self.register_pass_box.setText('')
173 self.email_box.setText('') 184 self.email_box.setText('')
174 self.right_side.selectTab(0) 185 self.right_side.selectTab(0)