[FIX]Minor changes.

bzr revid: vja@tinyerp.com-20120621090425-wa3lrw5tait9lt9s
This commit is contained in:
Vishmita 2012-06-21 14:34:25 +05:30
parent 87afddd907
commit 26dc7e2fa9
3 changed files with 28 additions and 22 deletions

View File

@ -437,18 +437,21 @@ class Database(openerpweb.Controller):
@openerpweb.httprequest
def backup(self, req, backup_db, backup_pwd, token):
db_dump = base64.b64decode(
req.session.proxy("db").dump(backup_pwd, backup_db))
filename = "%(db)s_%(timestamp)s.dump" % {
'db': backup_db,
'timestamp': datetime.datetime.utcnow().strftime(
"%Y-%m-%d_%H-%M-%SZ")
}
return req.make_response(db_dump,
[('Content-Type', 'application/octet-stream; charset=binary'),
('Content-Disposition', 'attachment; filename="' + filename + '"')],
{'fileToken': int(token)}
)
try:
db_dump = base64.b64decode(
req.session.proxy("db").dump(backup_pwd, backup_db))
filename = "%(db)s_%(timestamp)s.dump" % {
'db': backup_db,
'timestamp': datetime.datetime.utcnow().strftime(
"%Y-%m-%d_%H-%M-%SZ")
}
return req.make_response(db_dump,
[('Content-Type', 'application/octet-stream; charset=binary'),
('Content-Disposition', 'attachment; filename="' + filename + '"')],
{'fileToken': int(token)}
)
except xmlrpclib.Fault, e:
return simplejson.dumps([[],[{'error': e.faultCode, 'title': 'backup Database'}]])
@openerpweb.httprequest
def restore(self, req, db_file, restore_pwd, new_db):

View File

@ -392,13 +392,13 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
success: function () {
self.do_notify(_t("Backed"), _t("Database backed up successfully"));
},
error: function(){
if (instance.webclient.crashmanager.on_rpc_error) {
self.display_error({
error: function(error){
if(error){
self.display_error({
title: 'Backup Database',
error: 'AccessDenied'
});
}
});
}
},
complete: function() {
self.unblockUI();

View File

@ -332,11 +332,14 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
.appendTo(document.body)
.load(function () {
try {
if (options.error) {
options.error(JSON.parse(
this.contentDocument.body.childNodes[1].textContent
));
}
if (options.error) {
if (!this.contentDocument.body.childNodes[1]) {
options.error(this.contentDocument.body.childNodes);
}
else {
options.error(JSON.parse(this.contentDocument.body.childNodes[1].textContent));
}
}
} finally {
complete();
}