Antony Lesuisse (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-fixsignup-chs into lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-fixsignup-chs/+merge/131084
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-fixsignup-chs/+merge/131084
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-fixsignup-chs.
=== added file 'auth_signup/common.py'
--- auth_signup/common.py 1970-01-01 00:00:00 +0000
+++ auth_signup/common.py 2012-10-23 19:54:21 +0000
@@ -0,0 +1,2 @@
+class SignupError(Exception):
+ pass
=== modified file 'auth_signup/controllers/main.py'
--- auth_signup/controllers/main.py 2012-10-11 00:05:34 +0000
+++ auth_signup/controllers/main.py 2012-10-23 19:54:21 +0000
@@ -20,11 +20,10 @@
##############################################################################
import logging
-import werkzeug
-
import openerp
from openerp.modules.registry import RegistryManager
-from openerp.addons.web.controllers.main import login_and_redirect
+
+from ..common import SignupError
_logger = logging.getLogger(__name__)
@@ -41,22 +40,18 @@
user_info = res_partner.signup_retrieve_info(cr, openerp.SUPERUSER_ID, token)
return user_info
- @openerp.addons.web.http.httprequest
- def signup(self, req, dbname, token, name, login, password, state=''):
- """ sign up a user (new or existing), and log it in """
- url = '/'
+ @openerp.addons.web.http.jsonrequest
+ def signup(self, req, dbname, token, name, login, password):
+ """ sign up a user (new or existing)"""
registry = RegistryManager.get(dbname)
with registry.cursor() as cr:
+ res_users = registry.get('res.users')
+ values = {'name': name, 'login': login, 'password': password}
try:
- res_users = registry.get('res.users')
- values = {'name': name, 'login': login, 'password': password}
- credentials = res_users.signup(cr, openerp.SUPERUSER_ID, values, token)
- cr.commit()
- return login_and_redirect(req, *credentials, redirect_url='/#%s'%state)
- except Exception as e:
- # signup error
- _logger.exception('error when signup')
- url = "/#action=login&error_message=%s" % werkzeug.urls.url_quote(e.message)
- return werkzeug.utils.redirect(url)
+ res_users.signup(cr, openerp.SUPERUSER_ID, values, token)
+ except SignupError, e:
+ return {'error': openerp.tools.exception_to_unicode(e)}
+ cr.commit()
+ return {}
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'auth_signup/res_users.py'
--- auth_signup/res_users.py 2012-10-11 00:05:34 +0000
+++ auth_signup/res_users.py 2012-10-23 19:54:21 +0000
@@ -29,6 +29,8 @@
from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
from openerp.tools.safe_eval import safe_eval
+from .common import SignupError
+
def random_token():
# the token has an entropy of about 120 bits (6 bits/char * 20 chars)
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
@@ -101,12 +103,12 @@
partner_ids = self.search(cr, uid, [('signup_token', '=', token)], context=context)
if not partner_ids:
if raise_exception:
- raise Exception("Signup token '%s' is not valid" % token)
+ raise SignupError("Signup token '%s' is not valid" % token)
return False
partner = self.browse(cr, uid, partner_ids[0], context)
if check_validity and not partner.signup_valid:
if raise_exception:
- raise Exception("Signup token '%s' is no longer valid" % token)
+ raise SignupError("Signup token '%s' is no longer valid" % token)
return False
return partner
@@ -194,7 +196,7 @@
# check that uninvited users may sign up
if 'partner_id' not in values:
if not safe_eval(ir_config_parameter.get_param(cr, uid, 'auth_signup.allow_uninvited', 'False')):
- raise Exception('Signup is not allowed for uninvited users')
+ raise SignupError('Signup is not allowed for uninvited users')
# create a copy of the template user (attached to a specific partner_id if given)
values['active'] = True
=== modified file 'auth_signup/static/src/js/auth_signup.js'
--- auth_signup/static/src/js/auth_signup.js 2012-10-11 00:05:34 +0000
+++ auth_signup/static/src/js/auth_signup.js 2012-10-23 19:54:21 +0000
@@ -8,12 +8,20 @@
var d = this._super();
// to switch between the signup and regular login form
- this.$('a.oe_signup_signup').click(function() {
+ this.$('a.oe_signup_signup').click(function(ev) {
+ if (ev) {
+ ev.preventDefault();
+ }
self.$el.addClass("oe_login_signup");
+ return false;
});
- this.$('a.oe_signup_back').click(function() {
+ this.$('a.oe_signup_back').click(function(ev) {
+ if (ev) {
+ ev.preventDefault();
+ }
self.$el.removeClass("oe_login_signup");
delete self.params.token;
+ return false;
});
// if there is an error message in params, show it then forget it
@@ -90,10 +98,19 @@
name: name,
login: login,
password: password,
- state: $.param(this.params)
+ //state: $.param(this.params)
};
- var url = "/auth_signup/signup?" + $.param(params);
- window.location = url;
+
+ var self = this,
+ super_ = this._super;
+ this.rpc('/auth_signup/signup', params)
+ .done(function(result) {
+ if (result.error) {
+ self.show_error(result.error);
+ } else {
+ super_.apply(self, [ev]);
+ }
+ });
} else {
// regular login
this._super(ev);
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp