[FIX] Better error popup messages.
bzr revid: noz@tinyerp.com-20110713092242-0q5ii7haqfhldgtl
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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>");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -314,27 +314,16 @@ class JsonRequest(object):
|
||||
}
|
||||
}
|
||||
except xmlrpclib.Fault, e:
|
||||
if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied':
|
||||
message, string = e.faultCode.split(':')
|
||||
error = {
|
||||
'code': 200,
|
||||
'message': message,
|
||||
'data': {
|
||||
'type': 'server_exception',
|
||||
'debug': string
|
||||
}
|
||||
}
|
||||
else:
|
||||
error = {
|
||||
'code': 200,
|
||||
'message': "OpenERP Server Error",
|
||||
'data': {
|
||||
'type': 'server_exception',
|
||||
'fault_code': e.faultCode,
|
||||
'debug': "Client %s\nServer %s" % (
|
||||
"".join(traceback.format_exception("", None, sys.exc_traceback)), e.faultString)
|
||||
}
|
||||
error = {
|
||||
'code': 200,
|
||||
'message': "OpenERP Server Error",
|
||||
'data': {
|
||||
'type': 'server_exception',
|
||||
'fault_code': e.faultCode,
|
||||
'debug': "Client %s\nServer %s" % (
|
||||
"".join(traceback.format_exception("", None, sys.exc_traceback)), e.faultString)
|
||||
}
|
||||
}
|
||||
except Exception:
|
||||
cherrypy.log("An error occured while handling a json request",
|
||||
severity=logging.ERROR, traceback=True)
|
||||
|
||||
Reference in New Issue
Block a user