[FIX] Fix not working code, and some cleaning proposed by AL
bzr revid: vta@openerp.com-20121226181833-kih09glellxisl9p
This commit is contained in:
parent
78f36a2fce
commit
39e5509e6c
|
@ -656,9 +656,6 @@ class WebClient(openerpweb.Controller):
|
|||
def translations(self, req, mods, lang):
|
||||
res_lang = req.session.model('res.lang')
|
||||
ids = res_lang.search([("code", "=", lang)])
|
||||
if not ids:
|
||||
ids = res_lang.search([("iso_code", "=", lang)])
|
||||
lang = res_lang.search_read([('id', "in", ids)], ["code"])[0]['code']
|
||||
lang_params = None
|
||||
if ids:
|
||||
lang_params = res_lang.read(ids[0], ["direction", "date_format", "time_format",
|
||||
|
@ -800,9 +797,9 @@ class Session(openerpweb.Controller):
|
|||
return {
|
||||
"session_id": req.session_id,
|
||||
"uid": req.session._uid,
|
||||
"context": req.session.get_context() if req.session._uid else {},
|
||||
"user_context": req.session.get_context() if req.session._uid else {},
|
||||
"db": req.session._db,
|
||||
"login": req.session._login,
|
||||
"username": req.session._login,
|
||||
}
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
|
|
|
@ -22,7 +22,7 @@ class Service(object):
|
|||
def __init__(self, session, service_name):
|
||||
self.session = session
|
||||
self.service_name = service_name
|
||||
|
||||
|
||||
def __getattr__(self, method):
|
||||
def proxy_method(*args):
|
||||
result = self.session.send(self.service_name, method, *args)
|
||||
|
@ -60,7 +60,7 @@ class OpenERPSession(object):
|
|||
in a web session.
|
||||
|
||||
.. attribute:: context
|
||||
|
||||
|
||||
The session context, a ``dict``. Can be reloaded by calling
|
||||
:meth:`openerpweb.openerpweb.OpenERPSession.get_context`
|
||||
|
||||
|
@ -80,7 +80,7 @@ class OpenERPSession(object):
|
|||
self._suicide = False
|
||||
self.context = {}
|
||||
self.jsonp_requests = {} # FIXME use a LRU
|
||||
|
||||
|
||||
def send(self, service_name, method, *args):
|
||||
code_string = "warning -- %s\n\n%s"
|
||||
try:
|
||||
|
@ -112,7 +112,7 @@ class OpenERPSession(object):
|
|||
def authenticate(self, db, login, password, env=None):
|
||||
uid = self.proxy('common').authenticate(db, login, password, env)
|
||||
self.bind(db, uid, login, password)
|
||||
|
||||
|
||||
if uid: self.get_context()
|
||||
return uid
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2012, OpenERP S.A.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
@ -243,7 +243,7 @@ instance.web.ParentedMixin = {
|
|||
|
||||
/**
|
||||
* Backbone's events. Do not ever use it directly, use EventDispatcherMixin instead.
|
||||
*
|
||||
*
|
||||
* This class just handle the dispatching of events, it is not meant to be extended,
|
||||
* nor used directly. All integration with parenting and automatic unregistration of
|
||||
* events is done in EventDispatcherMixin.
|
||||
|
@ -303,7 +303,7 @@ var Events = instance.web.Class.extend({
|
|||
});
|
||||
return lst;
|
||||
},
|
||||
|
||||
|
||||
trigger : function(events) {
|
||||
var event, node, calls, tail, args, all, rest;
|
||||
if (!(calls = this._callbacks))
|
||||
|
@ -1043,7 +1043,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
id: payload.id,
|
||||
sid: this.httpsessionid,
|
||||
};
|
||||
|
||||
|
||||
var set_sid = function (response, textStatus, jqXHR) {
|
||||
// If response give us the http session id, we store it for next requests...
|
||||
if (response.httpsessionid) {
|
||||
|
@ -1054,7 +1054,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
url.url = this.url(url.url, null);
|
||||
var ajax = _.extend({
|
||||
type: "GET",
|
||||
dataType: 'jsonp',
|
||||
dataType: 'jsonp',
|
||||
jsonp: 'jsonp',
|
||||
cache: false,
|
||||
data: data
|
||||
|
|
|
@ -49,7 +49,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
_(this.module_list).each(function (mod) {
|
||||
self.module_loaded[mod] = true;
|
||||
});
|
||||
this.context = {};
|
||||
this.active_id = null;
|
||||
return this.session_init();
|
||||
},
|
||||
|
@ -67,7 +66,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
return deferred.then(function() { return self.load_modules(); });
|
||||
}
|
||||
return $.when(
|
||||
deferred,
|
||||
deferred,
|
||||
self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).then(function(trans) {
|
||||
instance.web._t.database.set_bundle(trans);
|
||||
})
|
||||
|
@ -86,13 +85,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
// If immediately follows a login (triggered by trying to restore
|
||||
// an invalid session or no session at all), refresh session data
|
||||
// (should not change, but just in case...)
|
||||
_.extend(self, {
|
||||
session_id: result.session_id,
|
||||
db: result.db,
|
||||
username: result.login,
|
||||
uid: result.uid,
|
||||
user_context: result.context
|
||||
});
|
||||
_.extend(self,result);
|
||||
});
|
||||
},
|
||||
session_is_valid: function() {
|
||||
|
@ -109,14 +102,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
if (!result.uid) {
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
_.extend(self, {
|
||||
session_id: result.session_id,
|
||||
db: result.db,
|
||||
username: result.login,
|
||||
uid: result.uid,
|
||||
user_context: result.context
|
||||
});
|
||||
_.extend(self, result);
|
||||
if (!_volatile) {
|
||||
self.set_cookie('session_id', self.session_id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue