Mercurial > libervia-web
comparison src/browser/sat_browser/register.py @ 871:54f6c5b86a87
server, browser: new "allow_registration" option to enable/disable new account registration through Liberia interface
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 29 Feb 2016 12:40:14 +0100 |
parents | 77a494f13118 |
children | 0d719b6a4115 |
comparison
equal
deleted
inserted
replaced
870:a05f3b24f2ec | 871:54f6c5b86a87 |
---|---|
46 | 46 |
47 | 47 |
48 | 48 |
49 class RegisterPanel(FormPanel): | 49 class RegisterPanel(FormPanel): |
50 | 50 |
51 def __init__(self, callback): | 51 def __init__(self, callback, session_data): |
52 """ | 52 """ |
53 @param callback: method to call if login successful | 53 @param callback(callable): method to call if login successful |
54 @param session_data(dict): session metadata | |
54 """ | 55 """ |
55 FormPanel.__init__(self) | 56 FormPanel.__init__(self) |
56 self.setSize('600px', '350px') | 57 self.setSize('600px', '350px') |
57 self.callback = callback | 58 self.callback = callback |
58 self.setMethod(FormPanel.METHOD_POST) | 59 self.setMethod(FormPanel.METHOD_POST) |
91 login_vpanel.add(self.login_pass_box) | 92 login_vpanel.add(self.login_pass_box) |
92 login_but = Button("Log in", getattr(self, "onLogin")) | 93 login_but = Button("Log in", getattr(self, "onLogin")) |
93 login_but.setStyleName('button') | 94 login_but.setStyleName('button') |
94 login_but.addStyleName('red') | 95 login_but.addStyleName('red') |
95 login_vpanel.add(login_but) | 96 login_vpanel.add(login_but) |
97 self.right_side.add(login_stack, 'Return to the login screen') | |
96 | 98 |
97 #The hidden submit_type field | 99 #The hidden submit_type field |
98 self.submit_type = Hidden('submit_type') | 100 self.submit_type = Hidden('submit_type') |
99 login_vpanel.add(self.submit_type) | 101 login_vpanel.add(self.submit_type) |
100 | 102 |
101 ##Register stack## | 103 ##Register stack## |
102 register_stack = SimplePanel() | 104 if session_data["allow_registration"]: |
103 register_stack.setStyleName('registerPanel_content') | 105 register_stack = SimplePanel() |
104 register_vpanel = VerticalPanel() | 106 register_stack.setStyleName('registerPanel_content') |
105 register_stack.setWidget(register_vpanel) | 107 register_vpanel = VerticalPanel() |
106 | 108 register_stack.setWidget(register_vpanel) |
107 self.register_warning_msg = HTML('') | 109 |
108 self.register_warning_msg.setStyleName('formWarning') | 110 self.register_warning_msg = HTML('') |
109 register_vpanel.add(self.register_warning_msg) | 111 self.register_warning_msg.setStyleName('formWarning') |
110 | 112 register_vpanel.add(self.register_warning_msg) |
111 register_login_label = Label('Login:') | 113 |
112 self.register_login_box = TextBox() | 114 register_login_label = Label('Login:') |
113 self.register_login_box.setName("register_login") | 115 self.register_login_box = TextBox() |
114 self.register_login_box.addKeyboardListener(self) | 116 self.register_login_box.setName("register_login") |
115 email_label = Label('E-mail:') | 117 self.register_login_box.addKeyboardListener(self) |
116 self.email_box = TextBox() | 118 email_label = Label('E-mail:') |
117 self.email_box.setName("email") | 119 self.email_box = TextBox() |
118 self.email_box.addKeyboardListener(self) | 120 self.email_box.setName("email") |
119 register_pass_label = Label('Password:') | 121 self.email_box.addKeyboardListener(self) |
120 self.register_pass_box = PasswordTextBox() | 122 register_pass_label = Label('Password:') |
121 self.register_pass_box.setName("register_password") | 123 self.register_pass_box = PasswordTextBox() |
122 self.register_pass_box.addKeyboardListener(self) | 124 self.register_pass_box.setName("register_password") |
123 register_vpanel.add(register_login_label) | 125 self.register_pass_box.addKeyboardListener(self) |
124 register_vpanel.add(self.register_login_box) | 126 register_vpanel.add(register_login_label) |
125 register_vpanel.add(email_label) | 127 register_vpanel.add(self.register_login_box) |
126 register_vpanel.add(self.email_box) | 128 register_vpanel.add(email_label) |
127 register_vpanel.add(register_pass_label) | 129 register_vpanel.add(self.email_box) |
128 register_vpanel.add(self.register_pass_box) | 130 register_vpanel.add(register_pass_label) |
129 | 131 register_vpanel.add(self.register_pass_box) |
130 register_but = Button("Register a new account", getattr(self, "onRegister")) | 132 |
131 register_but.setStyleName('button') | 133 register_but = Button("Register a new account", getattr(self, "onRegister")) |
132 register_but.addStyleName('red') | 134 register_but.setStyleName('button') |
133 register_vpanel.add(register_but) | 135 register_but.addStyleName('red') |
134 | 136 register_vpanel.add(register_but) |
135 self.right_side.add(login_stack, 'Return to the login screen') | 137 |
136 self.right_side.add(register_stack, 'No account yet? Create a new one!') | 138 self.right_side.add(register_stack, 'No account yet? Create a new one!') |
137 self.right_side.addStackChangeListener(self) | 139 self.right_side.addStackChangeListener(self) |
140 register_stack.setWidth(None) | |
138 login_stack.setWidth(None) | 141 login_stack.setWidth(None) |
139 register_stack.setWidth(None) | |
140 | 142 |
141 self.add(main_panel) | 143 self.add(main_panel) |
142 self.addFormHandler(self) | 144 self.addFormHandler(self) |
143 self.setAction('register_api/login') | 145 self.setAction('register_api/login') |
144 | 146 |
266 JS("""return /^(\w|-|\.|\+)+(@(\w|-)+\.(\w|-)+)?$/.test(text);""") | 268 JS("""return /^(\w|-|\.|\+)+(@(\w|-)+\.(\w|-)+)?$/.test(text);""") |
267 | 269 |
268 | 270 |
269 class RegisterBox(PopupPanel): | 271 class RegisterBox(PopupPanel): |
270 | 272 |
271 def __init__(self, callback, *args, **kwargs): | 273 def __init__(self, callback, session_data, *args, **kwargs): |
272 PopupPanel.__init__(self, *args, **kwargs) | 274 PopupPanel.__init__(self, *args, **kwargs) |
273 self._form = RegisterPanel(callback) | 275 self._form = RegisterPanel(callback, session_data) |
274 self.setWidget(self._form) | 276 self.setWidget(self._form) |
275 | 277 |
276 def onWindowResized(self, width, height): | 278 def onWindowResized(self, width, height): |
277 super(RegisterBox, self).onWindowResized(width, height) | 279 super(RegisterBox, self).onWindowResized(width, height) |
278 self.centerBox() | 280 self.centerBox() |