diff options
| author | noz (OpenERP) <noz@tinyerp.com> | 2011-07-13 14:52:42 +0530 |
|---|---|---|
| committer | noz (OpenERP) <noz@tinyerp.com> | 2011-07-13 14:52:42 +0530 |
| commit | 59bb0fd4e637cd4100e53d24df184ad5c53ed86b (patch) | |
| tree | 39467a62958231c0aa467cd324893911b8f102df /addons/base | |
| parent | 673762cbee421c6a65a08c8bfb06d9aca57d405e (diff) | |
[FIX] Better error popup messages.
bzr revid: noz@tinyerp.com-20110713092242-0q5ii7haqfhldgtl
Diffstat (limited to 'addons/base')
| -rw-r--r-- | addons/base/controllers/main.py | 34 | ||||
| -rw-r--r-- | addons/base/static/src/js/chrome.js | 95 |
2 files changed, 98 insertions, 31 deletions
diff --git a/addons/base/controllers/main.py b/addons/base/controllers/main.py index 2df86d3ce7e..618d86f3750 100644 --- a/addons/base/controllers/main.py +++ b/addons/base/controllers/main.py @@ -130,7 +130,13 @@ class Session(openerpweb.Controller): db = kw.get('db') password = kw.get('password') - return req.session.proxy("db").drop(password, db) + try: + return req.session.proxy("db").drop(password, db) + except Exception, e: + if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied': + return {'error': 'Bad super admin password !'} + else: + return {'error': 'Could not drop database !'} elif flag == 'backup': db = kw.get('db') @@ -141,8 +147,11 @@ class Session(openerpweb.Controller): cherrypy.response.headers['Content-Type'] = "application/data" cherrypy.response.headers['Content-Disposition'] = 'filename="' + db + '.dump"' return base64.decodestring(res) - except Exception: - return {'error': 'Could not create backup !'} + except Exception, e: + if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied': + return {'error': 'Bad super admin password !'} + else: + return {'error': 'Could not drop database !'} elif flag == 'restore': filename = kw.get('filename') @@ -150,19 +159,26 @@ class Session(openerpweb.Controller): password = kw.get('password') try: - if filename: - data = base64.encodestring(filename.file.read()) - return req.session.proxy("db").restore(password, db, data) - except Exception: - return {'error': 'Could not restore database !'} + data = base64.encodestring(filename.file.read()) + return req.session.proxy("db").restore(password, db, data) + except Exception, e: + if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied': + return {'error': 'Bad super admin password !'} + else: + return {'error': 'Could not restore database !'} elif flag == 'change_password': old_password = kw.get('old_password') new_password = kw.get('new_password') confirm_password = kw.get('confirm_password') - if old_password and new_password and confirm_password: + try: return req.session.proxy("db").change_admin_password(old_password, new_password) + except Exception, e: + if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied': + return {'error': 'Bad super admin password !'} + else: + return {'error': 'Error, password not changed !'} @openerpweb.jsonrequest def modules(self, req): diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index db831387823..47e3de67677 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -974,18 +974,29 @@ openerp.base.Database = openerp.base.Controller.extend({ demo_data = 'False'; self.rpc("/base/session/db_operation", { - 'flag': 'create', - 'super_admin_pwd': super_admin_pwd, - 'db': db, - 'demo_data': demo_data, - 'db_lang': db_lang, - 'admin_pwd': admin_pwd, - 'confirm_pwd': confirm_pwd - }, - function(result) { - if (result && !result.error) { - - } + 'flag': 'create', + 'super_admin_pwd': super_admin_pwd, + 'db': db, + 'demo_data': demo_data, + 'db_lang': db_lang, + 'admin_pwd': admin_pwd, + 'confirm_pwd': confirm_pwd + }, + function(result) { + if (result && !result.error) { + + } else if(result.error) { + var db_error_dialog = _.uniqueId("db_error_dialog"); + $('<div>', {id: db_error_dialog}).dialog({ + modal: true, + title: "Create Database", + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }).html("<center style='padding-top: 15px; font-size: 15px'>" + result.error + "</center>"); + } }); }); }, @@ -1005,12 +1016,23 @@ openerp.base.Database = openerp.base.Controller.extend({ if (confirm("Do you really want to delete the database: " + db + " ?")) { self.rpc("/base/session/db_operation", {'flag': 'drop', 'db': db, 'password': password}, - function(result) { - if (result && !result.error) { - self.$option_id.find("select[name=drop_db] :selected").remove(); - self.notification.notify("Dropping database", "The database '" + db + "' has been dropped"); - } - }); + function(result) { + if (result && ! result.error) { + self.$option_id.find("select[name=drop_db] :selected").remove(); + self.notification.notify("Dropping database", "The database '" + db + "' has been dropped"); + } else if(result.error) { + var db_error_dialog = _.uniqueId("db_error_dialog"); + $('<div>', {id: db_error_dialog}).dialog({ + modal: true, + title: "Drop Database", + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }).html("<center style='padding-top: 15px; font-size: 15px'>" + result.error + "</center>"); + } + }); } }); }, @@ -1032,8 +1054,17 @@ openerp.base.Database = openerp.base.Controller.extend({ function(result) { if (result && !result.error) { self.notification.notify("Backup Database", "Backup has been created for the database: '" + db + "'"); - } else if (result.error) { - self.notification.notify("Backup Database", result.error); + } else if(result.error) { + var db_error_dialog = _.uniqueId("db_error_dialog"); + $('<div>', {id: db_error_dialog}).dialog({ + modal: true, + title: "Backup Database", + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }).html("<center style='padding-top: 15px; font-size: 15px'>" + result.error + "</center>"); } }); }); @@ -1057,8 +1088,17 @@ openerp.base.Database = openerp.base.Controller.extend({ function(result) { if (result && !result.error) { self.notification.notify("Restore Database", "You restored your database as: '" + new_db + "'"); - } else if (result.error) { - self.notification.notify("Restore Database", result.error); + } else if(result.error) { + var db_error_dialog = _.uniqueId("db_error_dialog"); + $('<div>', {id: db_error_dialog}).dialog({ + modal: true, + title: "Restore Database", + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }).html("<center style='padding-top: 15px; font-size: 15px'>" + result.error + "</center>"); } }); }); @@ -1103,6 +1143,17 @@ openerp.base.Database = openerp.base.Controller.extend({ function(result) { if (result && !result.error) { self.notification.notify("Changed Password", "Password has been changed successfully"); + } else if(result.error) { + var db_error_dialog = _.uniqueId("db_error_dialog"); + $('<div>', {id: db_error_dialog}).dialog({ + modal: true, + title: "Change Password", + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }).html("<center style='padding-top: 15px; font-size: 15px'>" + result.error + "</center>"); } }); }); |
