summaryrefslogtreecommitdiff
path: root/addons/auth_signup/controllers/main.py
diff options
context:
space:
mode:
authorDenis Vermylen <dve@odoo.com>2017-05-15 15:14:49 +0200
committerThibault Delavallée <tde@odoo.com>2017-07-06 12:53:39 +0200
commit676022e3afdd774c3e0c78cb26c0062133043308 (patch)
tree4ebb9a52d9bb10518ab3cd9242a3ac1786280488 /addons/auth_signup/controllers/main.py
parent689d6d68296ea32c2155dc1a61b593754ca3b968 (diff)
[IMP] auth_signup: display meaningfull and translated error messages
Since 5425316eff19e7ae716aafdb730c92d1b3ea2abb errors when signing up will only display two messages: * "Another user is already registered using this email address." or * "Could not create a new account." While Odoo creates a multitude of other comprehensible error messages such as * "Passwords do not match; please retype them." * "Signup token '%s' is no longer valid" This commit now separate UserError and AssertionError from SignupErrors. Those are still hidden in a general message (see 5425316eff19e7ae716aafdb730c92d1b3ea2abb for reasons) while the other ones are fully displayed. This commit also improves translations of messages.
Diffstat (limited to 'addons/auth_signup/controllers/main.py')
-rw-r--r--addons/auth_signup/controllers/main.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py
index 533f84a8d82..0b546011b27 100644
--- a/addons/auth_signup/controllers/main.py
+++ b/addons/auth_signup/controllers/main.py
@@ -6,6 +6,7 @@ import werkzeug
from odoo import http, _
from odoo.addons.auth_signup.models.res_users import SignupError
from odoo.addons.web.controllers.main import ensure_db, Home
+from odoo.exceptions import UserError
from odoo.http import request
from odoo.tools import pycompat
@@ -34,6 +35,8 @@ class AuthSignupHome(Home):
try:
self.do_signup(qcontext)
return super(AuthSignupHome, self).web_login(*args, **kw)
+ except UserError as e:
+ qcontext['error'] = str(e)
except (SignupError, AssertionError) as e:
if request.env["res.users"].sudo().search([("login", "=", qcontext.get("login"))]):
qcontext["error"] = _("Another user is already registered using this email address.")
@@ -57,7 +60,7 @@ class AuthSignupHome(Home):
return super(AuthSignupHome, self).web_login(*args, **kw)
else:
login = qcontext.get('login')
- assert login, "No login provided."
+ assert login, _("No login provided.")
_logger.info(
"Password reset attempt for <%s> by user <%s> from %s",
login, request.env.user.login, request.httprequest.remote_addr)
@@ -100,8 +103,10 @@ class AuthSignupHome(Home):
def do_signup(self, qcontext):
""" Shared helper that creates a res.partner out of a token """
values = { key: qcontext.get(key) for key in ('login', 'name', 'password') }
- assert values, "The form was not properly filled in."
- assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them."
+ if not values:
+ raise UserError(_("The form was not properly filled in."))
+ if values.get('password') != qcontext.get('confirm_password'):
+ raise UserError(_("Passwords do not match; please retype them."))
supported_langs = [lang['code'] for lang in request.env['res.lang'].sudo().search_read([], ['code'])]
if request.lang in supported_langs:
values['lang'] = request.lang