From 0452790388eecdc472bbc54bd6847c6df1104cc9 Mon Sep 17 00:00:00 2001 From: ggh-openerp Date: Mon, 12 Nov 2012 18:37:56 +0530 Subject: [PATCH 1/5] [IMP] Improve Change Password dailog bzr revid: ggh@tinyerp.com-20121112130756-jtj6u56pcvxorxcr --- addons/web/static/src/js/chrome.js | 4 ++++ addons/web/static/src/xml/base.xml | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 69dafa08c02..7717815179f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -667,6 +667,10 @@ instance.web.ChangePassword = instance.web.Widget.extend({ template: "ChangePassword", start: function() { var self = this; + var $button = self.$el.find('.oe_form_button'); + var footer_panel = this.getParent().$buttons.find('footer'); + $button.eq(0).prependTo(footer_panel); + $button.eq(1).appendTo(footer_panel); self.$el.validate({ submitHandler: function (form) { self.rpc("/web/session/change_password",{ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 215374cb6fb..c295bb06c21 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -288,26 +288,30 @@
+
- - + - - + - - + - + -
+ + +
+
From 5e948944a097889626801f2ed540ada9a7786a1c Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 16 Nov 2012 16:38:38 +0530 Subject: [PATCH 2/5] [IMP]Improve code for change password dialog bzr revid: vja@tinyerp.com-20121116110838-zqwt9mkx5prooqzq --- addons/web/static/src/js/chrome.js | 31 +++++++++++++++--------------- addons/web/static/src/xml/base.xml | 5 +++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 7717815179f..4d5d09e65ad 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -669,22 +669,21 @@ instance.web.ChangePassword = instance.web.Widget.extend({ var self = this; var $button = self.$el.find('.oe_form_button'); var footer_panel = this.getParent().$buttons.find('footer'); - $button.eq(0).prependTo(footer_panel); - $button.eq(1).appendTo(footer_panel); - self.$el.validate({ - submitHandler: function (form) { - self.rpc("/web/session/change_password",{ - 'fields': $(form).serializeArray() - }).done(function(result) { - if (result.error) { - self.display_error(result); - return; - } else { - instance.webclient.on_logout(); - } - }); - } - }); + $button.eq(1).appendTo(footer_panel).click(function(){ + self.getParent().close(); + }) + $button.eq(0).prependTo(footer_panel).click(function(){ + self.rpc("/web/session/change_password",{ + 'fields': $("form[name=change_password_form]").serializeArray() + }).done(function(result) { + if (result.error) { + self.display_error(result); + return; + } else { + instance.webclient.on_logout(); + } + }); + }) }, display_error: function (error) { return instance.web.dialog($('
'), { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index c295bb06c21..8d0ed7d9605 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -288,7 +288,7 @@
-
+
@@ -311,7 +311,8 @@ -
+ +
From e97d0843c377f43b86122f9d0e31f0d4426523ee Mon Sep 17 00:00:00 2001 From: Vishmita Date: Mon, 19 Nov 2012 12:41:42 +0530 Subject: [PATCH 3/5] [IMP]Minor Change bzr revid: vja@tinyerp.com-20121119071142-8z4tyac5t8614dde --- addons/web/static/src/js/chrome.js | 7 ++++--- addons/web/static/src/xml/base.xml | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 94ddd8f33c8..c3935effdeb 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -720,12 +720,13 @@ instance.web.ChangePassword = instance.web.Widget.extend({ template: "ChangePassword", start: function() { var self = this; + this.getParent().dialog_title = "Change Password"; var $button = self.$el.find('.oe_form_button'); - var footer_panel = this.getParent().$buttons.find('footer'); - $button.eq(1).appendTo(footer_panel).click(function(){ + $button.appendTo(this.getParent().$buttons); + $button.eq(2).click(function(){ self.getParent().close(); }) - $button.eq(0).prependTo(footer_panel).click(function(){ + $button.eq(0).click(function(){ self.rpc("/web/session/change_password",{ 'fields': $("form[name=change_password_form]").serializeArray() }).done(function(result) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index f48650d0115..33997b7a920 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -335,6 +335,7 @@ + or From 3b07266500b246717a25a09491b548bc571c66a9 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Tue, 20 Nov 2012 12:59:57 +0530 Subject: [PATCH 4/5] [IMP]Minor Changes related to terminology for Change Password dialog pop-up bzr revid: vja@tinyerp.com-20121120072957-rrjlbwkn6tkdmqkc --- addons/web/controllers/main.py | 8 ++++---- addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index fb7b45a4056..0155d4149a2 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -890,15 +890,15 @@ class Session(openerpweb.Controller): old_password, new_password,confirm_password = operator.itemgetter('old_pwd', 'new_password','confirm_pwd')( dict(map(operator.itemgetter('name', 'value'), fields))) if not (old_password.strip() and new_password.strip() and confirm_password.strip()): - return {'error':'All passwords have to be filled.','title': 'Change Password'} - if new_password != confirm_password: - return {'error': 'The new password and its confirmation must be identical.','title': 'Change Password'} + return {'error':'You cannot leave any password empty.','title': 'Change Password'} try: if req.session.model('res.users').change_password( old_password, new_password): return {'new_password':new_password} except Exception: - return {'error': 'Original password incorrect, your password was not changed.', 'title': 'Change Password'} + return {'error': 'The Old Password you provided is incorrect. Please try again.', 'title': 'Change Password'} + if new_password != confirm_password: + return {'error': 'The new password and its confirmation must be identical.','title': 'Change Password'} return {'error': 'Error, password not changed !', 'title': 'Change Password'} @openerpweb.jsonrequest diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 33997b7a920..a20c10c0589 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -328,7 +328,7 @@ minlength="1"/> - + From b8836ee8092286c69b89bf2687fed001fdfbb2d0 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Tue, 20 Nov 2012 18:01:31 +0530 Subject: [PATCH 5/5] [IMP]Set Priority to display warning messages for change password dialog bzr revid: vja@tinyerp.com-20121120123131-9boe1y6ki0sy2h3c --- addons/web/controllers/main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 0155d4149a2..181bb31d43e 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -891,15 +891,19 @@ class Session(openerpweb.Controller): dict(map(operator.itemgetter('name', 'value'), fields))) if not (old_password.strip() and new_password.strip() and confirm_password.strip()): return {'error':'You cannot leave any password empty.','title': 'Change Password'} + user_pwd = req.session.model('res.users').read([req.session._uid], ['password'], None)[0]['password'] try: - if req.session.model('res.users').change_password( - old_password, new_password): - return {'new_password':new_password} + if old_password == user_pwd: + if old_password == new_password: + return {'error':'New password must be different from the old password. Please try again.','title': 'Change Password'} + elif new_password != confirm_password: + return {'error': 'The new password and its confirmation must be identical.','title': 'Change Password'} + elif req.session.model('res.users').change_password(old_password, new_password): + return {'new_password':new_password} + else: + return {'error': 'The Old Password you provided is incorrect. Please try again.', 'title': 'Change Password'} except Exception: - return {'error': 'The Old Password you provided is incorrect. Please try again.', 'title': 'Change Password'} - if new_password != confirm_password: - return {'error': 'The new password and its confirmation must be identical.','title': 'Change Password'} - return {'error': 'Error, password not changed !', 'title': 'Change Password'} + return {'error': 'Error, password not changed !', 'title': 'Change Password'} @openerpweb.jsonrequest def sc_list(self, req):