Merge lp:~openerp-dev/openerp-web/7.0-anonymous_lang-vta into lp:openerp-web/7.0

Proposed by Victor Tabuenca (OpenERP)
Status: Merged
Merged at revision: 3664
Proposed branch: lp:~openerp-dev/openerp-web/7.0-anonymous_lang-vta
Merge into: lp:openerp-web/7.0
Diff against target: 206 lines (+23/-37)
4 files modified
addons/web/controllers/main.py (+6/-6)
addons/web/session.py (+4/-4)
addons/web/static/src/js/corelib.js (+10/-10)
addons/web/static/src/js/coresetup.js (+3/-17)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-anonymous_lang-vta
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+141282@code.launchpad.net

Description of the change

Make browser's lang the anonymous user language

To post a comment you must log in.
3663. By vta <email address hidden>

[FIX] Spacing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py 2012-12-19 15:45:05 +0000
+++ addons/web/controllers/main.py 2012-12-27 07:46:22 +0000
@@ -668,7 +668,7 @@
668 messages = ir_translation.search_read([('module','in',mods),('lang','=',lang),668 messages = ir_translation.search_read([('module','in',mods),('lang','=',lang),
669 ('comments','like','openerp-web'),('value','!=',False),669 ('comments','like','openerp-web'),('value','!=',False),
670 ('value','!=','')],670 ('value','!=','')],
671 ['module','src','value','lang'], order='module') 671 ['module','src','value','lang'], order='module')
672 for mod, msg_group in itertools.groupby(messages, key=operator.itemgetter('module')):672 for mod, msg_group in itertools.groupby(messages, key=operator.itemgetter('module')):
673 translations_per_module.setdefault(mod,{'messages':[]})673 translations_per_module.setdefault(mod,{'messages':[]})
674 translations_per_module[mod]['messages'].extend({'id': m['src'],674 translations_per_module[mod]['messages'].extend({'id': m['src'],
@@ -797,9 +797,9 @@
797 return {797 return {
798 "session_id": req.session_id,798 "session_id": req.session_id,
799 "uid": req.session._uid,799 "uid": req.session._uid,
800 "context": req.session.get_context() if req.session._uid else {},800 "user_context": req.session.get_context() if req.session._uid else {},
801 "db": req.session._db,801 "db": req.session._db,
802 "login": req.session._login,802 "username": req.session._login,
803 }803 }
804804
805 @openerpweb.jsonrequest805 @openerpweb.jsonrequest
@@ -1072,7 +1072,7 @@
1072 @openerpweb.jsonrequest1072 @openerpweb.jsonrequest
1073 def call(self, req, model, method, args, domain_id=None, context_id=None):1073 def call(self, req, model, method, args, domain_id=None, context_id=None):
1074 return self._call_kw(req, model, method, args, {})1074 return self._call_kw(req, model, method, args, {})
1075 1075
1076 @openerpweb.jsonrequest1076 @openerpweb.jsonrequest
1077 def call_kw(self, req, model, method, args, kwargs):1077 def call_kw(self, req, model, method, args, kwargs):
1078 return self._call_kw(req, model, method, args, kwargs)1078 return self._call_kw(req, model, method, args, kwargs)
@@ -1186,7 +1186,7 @@
1186 if width > 500: width = 5001186 if width > 500: width = 500
1187 if height > 500: height = 5001187 if height > 500: height = 500
1188 image_base64 = openerp.tools.image_resize_image(base64_source=image_base64, size=(width, height), encoding='base64', filetype='PNG')1188 image_base64 = openerp.tools.image_resize_image(base64_source=image_base64, size=(width, height), encoding='base64', filetype='PNG')
1189 1189
1190 image_data = base64.b64decode(image_base64)1190 image_data = base64.b64decode(image_base64)
11911191
1192 except (TypeError, xmlrpclib.Fault):1192 except (TypeError, xmlrpclib.Fault):
@@ -1468,7 +1468,7 @@
1468 fields = self.fields_get(req, model)1468 fields = self.fields_get(req, model)
1469 if ".id" in export_fields:1469 if ".id" in export_fields:
1470 fields['.id'] = fields.pop('id', {'string': 'ID'})1470 fields['.id'] = fields.pop('id', {'string': 'ID'})
1471 1471
1472 # To make fields retrieval more efficient, fetch all sub-fields of a1472 # To make fields retrieval more efficient, fetch all sub-fields of a
1473 # given field at the same time. Because the order in the export list is1473 # given field at the same time. Because the order in the export list is
1474 # arbitrary, this requires ordering all sub-fields of a given field1474 # arbitrary, this requires ordering all sub-fields of a given field
14751475
=== modified file 'addons/web/session.py'
--- addons/web/session.py 2012-12-17 10:01:27 +0000
+++ addons/web/session.py 2012-12-27 07:46:22 +0000
@@ -22,7 +22,7 @@
22 def __init__(self, session, service_name):22 def __init__(self, session, service_name):
23 self.session = session23 self.session = session
24 self.service_name = service_name24 self.service_name = service_name
25 25
26 def __getattr__(self, method):26 def __getattr__(self, method):
27 def proxy_method(*args):27 def proxy_method(*args):
28 result = self.session.send(self.service_name, method, *args)28 result = self.session.send(self.service_name, method, *args)
@@ -60,7 +60,7 @@
60 in a web session.60 in a web session.
6161
62 .. attribute:: context62 .. attribute:: context
63 63
64 The session context, a ``dict``. Can be reloaded by calling64 The session context, a ``dict``. Can be reloaded by calling
65 :meth:`openerpweb.openerpweb.OpenERPSession.get_context`65 :meth:`openerpweb.openerpweb.OpenERPSession.get_context`
6666
@@ -80,7 +80,7 @@
80 self._suicide = False80 self._suicide = False
81 self.context = {}81 self.context = {}
82 self.jsonp_requests = {} # FIXME use a LRU82 self.jsonp_requests = {} # FIXME use a LRU
83 83
84 def send(self, service_name, method, *args):84 def send(self, service_name, method, *args):
85 code_string = "warning -- %s\n\n%s"85 code_string = "warning -- %s\n\n%s"
86 try:86 try:
@@ -112,7 +112,7 @@
112 def authenticate(self, db, login, password, env=None):112 def authenticate(self, db, login, password, env=None):
113 uid = self.proxy('common').authenticate(db, login, password, env)113 uid = self.proxy('common').authenticate(db, login, password, env)
114 self.bind(db, uid, login, password)114 self.bind(db, uid, login, password)
115 115
116 if uid: self.get_context()116 if uid: self.get_context()
117 return uid117 return uid
118118
119119
=== modified file 'addons/web/static/src/js/corelib.js'
--- addons/web/static/src/js/corelib.js 2012-11-30 10:36:51 +0000
+++ addons/web/static/src/js/corelib.js 2012-12-27 07:46:22 +0000
@@ -1,16 +1,16 @@
1/*1/*
2 * Copyright (c) 2012, OpenERP S.A.2 * Copyright (c) 2012, OpenERP S.A.
3 * All rights reserved.3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer. 9 * list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -243,7 +243,7 @@
243243
244/**244/**
245 * Backbone's events. Do not ever use it directly, use EventDispatcherMixin instead.245 * Backbone's events. Do not ever use it directly, use EventDispatcherMixin instead.
246 * 246 *
247 * This class just handle the dispatching of events, it is not meant to be extended,247 * This class just handle the dispatching of events, it is not meant to be extended,
248 * nor used directly. All integration with parenting and automatic unregistration of248 * nor used directly. All integration with parenting and automatic unregistration of
249 * events is done in EventDispatcherMixin.249 * events is done in EventDispatcherMixin.
@@ -303,7 +303,7 @@
303 });303 });
304 return lst;304 return lst;
305 },305 },
306 306
307 trigger : function(events) {307 trigger : function(events) {
308 var event, node, calls, tail, args, all, rest;308 var event, node, calls, tail, args, all, rest;
309 if (!(calls = this._callbacks))309 if (!(calls = this._callbacks))
@@ -1043,7 +1043,7 @@
1043 id: payload.id,1043 id: payload.id,
1044 sid: this.httpsessionid,1044 sid: this.httpsessionid,
1045 };1045 };
1046 1046
1047 var set_sid = function (response, textStatus, jqXHR) {1047 var set_sid = function (response, textStatus, jqXHR) {
1048 // If response give us the http session id, we store it for next requests...1048 // If response give us the http session id, we store it for next requests...
1049 if (response.httpsessionid) {1049 if (response.httpsessionid) {
@@ -1054,7 +1054,7 @@
1054 url.url = this.url(url.url, null);1054 url.url = this.url(url.url, null);
1055 var ajax = _.extend({1055 var ajax = _.extend({
1056 type: "GET",1056 type: "GET",
1057 dataType: 'jsonp', 1057 dataType: 'jsonp',
1058 jsonp: 'jsonp',1058 jsonp: 'jsonp',
1059 cache: false,1059 cache: false,
1060 data: data1060 data: data
10611061
=== modified file 'addons/web/static/src/js/coresetup.js'
--- addons/web/static/src/js/coresetup.js 2012-12-19 15:12:17 +0000
+++ addons/web/static/src/js/coresetup.js 2012-12-27 07:46:22 +0000
@@ -49,7 +49,6 @@
49 _(this.module_list).each(function (mod) {49 _(this.module_list).each(function (mod) {
50 self.module_loaded[mod] = true;50 self.module_loaded[mod] = true;
51 });51 });
52 this.context = {};
53 this.active_id = null;52 this.active_id = null;
54 return this.session_init();53 return this.session_init();
55 },54 },
@@ -67,7 +66,7 @@
67 return deferred.then(function() { return self.load_modules(); });66 return deferred.then(function() { return self.load_modules(); });
68 }67 }
69 return $.when(68 return $.when(
70 deferred, 69 deferred,
71 self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).then(function(trans) {70 self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).then(function(trans) {
72 instance.web._t.database.set_bundle(trans);71 instance.web._t.database.set_bundle(trans);
73 })72 })
@@ -86,13 +85,7 @@
86 // If immediately follows a login (triggered by trying to restore85 // If immediately follows a login (triggered by trying to restore
87 // an invalid session or no session at all), refresh session data86 // an invalid session or no session at all), refresh session data
88 // (should not change, but just in case...)87 // (should not change, but just in case...)
89 _.extend(self, {88 _.extend(self, result);
90 session_id: result.session_id,
91 db: result.db,
92 username: result.login,
93 uid: result.uid,
94 user_context: result.context
95 });
96 });89 });
97 },90 },
98 session_is_valid: function() {91 session_is_valid: function() {
@@ -109,14 +102,7 @@
109 if (!result.uid) {102 if (!result.uid) {
110 return $.Deferred().reject();103 return $.Deferred().reject();
111 }104 }
112105 _.extend(self, result);
113 _.extend(self, {
114 session_id: result.session_id,
115 db: result.db,
116 username: result.login,
117 uid: result.uid,
118 user_context: result.context
119 });
120 if (!_volatile) {106 if (!_volatile) {
121 self.set_cookie('session_id', self.session_id);107 self.set_cookie('session_id', self.session_id);
122 }108 }