Merge lp:~openerp-dev/openerp-web/7.0-anonymous_lang-vta into lp:openerp-web/7.0
- 7.0-anonymous_lang-vta
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+141282@code.launchpad.net |
Commit message
Description of the change
Make browser's lang the anonymous user language
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'addons/web/controllers/main.py' | |||
2 | --- addons/web/controllers/main.py 2012-12-19 15:45:05 +0000 | |||
3 | +++ addons/web/controllers/main.py 2012-12-27 07:46:22 +0000 | |||
4 | @@ -668,7 +668,7 @@ | |||
5 | 668 | messages = ir_translation.search_read([('module','in',mods),('lang','=',lang), | 668 | messages = ir_translation.search_read([('module','in',mods),('lang','=',lang), |
6 | 669 | ('comments','like','openerp-web'),('value','!=',False), | 669 | ('comments','like','openerp-web'),('value','!=',False), |
7 | 670 | ('value','!=','')], | 670 | ('value','!=','')], |
9 | 671 | ['module','src','value','lang'], order='module') | 671 | ['module','src','value','lang'], order='module') |
10 | 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')): |
11 | 673 | translations_per_module.setdefault(mod,{'messages':[]}) | 673 | translations_per_module.setdefault(mod,{'messages':[]}) |
12 | 674 | translations_per_module[mod]['messages'].extend({'id': m['src'], | 674 | translations_per_module[mod]['messages'].extend({'id': m['src'], |
13 | @@ -797,9 +797,9 @@ | |||
14 | 797 | return { | 797 | return { |
15 | 798 | "session_id": req.session_id, | 798 | "session_id": req.session_id, |
16 | 799 | "uid": req.session._uid, | 799 | "uid": req.session._uid, |
18 | 800 | "context": req.session.get_context() if req.session._uid else {}, | 800 | "user_context": req.session.get_context() if req.session._uid else {}, |
19 | 801 | "db": req.session._db, | 801 | "db": req.session._db, |
21 | 802 | "login": req.session._login, | 802 | "username": req.session._login, |
22 | 803 | } | 803 | } |
23 | 804 | 804 | ||
24 | 805 | @openerpweb.jsonrequest | 805 | @openerpweb.jsonrequest |
25 | @@ -1072,7 +1072,7 @@ | |||
26 | 1072 | @openerpweb.jsonrequest | 1072 | @openerpweb.jsonrequest |
27 | 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): |
28 | 1074 | return self._call_kw(req, model, method, args, {}) | 1074 | return self._call_kw(req, model, method, args, {}) |
30 | 1075 | 1075 | ||
31 | 1076 | @openerpweb.jsonrequest | 1076 | @openerpweb.jsonrequest |
32 | 1077 | def call_kw(self, req, model, method, args, kwargs): | 1077 | def call_kw(self, req, model, method, args, kwargs): |
33 | 1078 | return self._call_kw(req, model, method, args, kwargs) | 1078 | return self._call_kw(req, model, method, args, kwargs) |
34 | @@ -1186,7 +1186,7 @@ | |||
35 | 1186 | if width > 500: width = 500 | 1186 | if width > 500: width = 500 |
36 | 1187 | if height > 500: height = 500 | 1187 | if height > 500: height = 500 |
37 | 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') |
39 | 1189 | 1189 | ||
40 | 1190 | image_data = base64.b64decode(image_base64) | 1190 | image_data = base64.b64decode(image_base64) |
41 | 1191 | 1191 | ||
42 | 1192 | except (TypeError, xmlrpclib.Fault): | 1192 | except (TypeError, xmlrpclib.Fault): |
43 | @@ -1468,7 +1468,7 @@ | |||
44 | 1468 | fields = self.fields_get(req, model) | 1468 | fields = self.fields_get(req, model) |
45 | 1469 | if ".id" in export_fields: | 1469 | if ".id" in export_fields: |
46 | 1470 | fields['.id'] = fields.pop('id', {'string': 'ID'}) | 1470 | fields['.id'] = fields.pop('id', {'string': 'ID'}) |
48 | 1471 | 1471 | ||
49 | 1472 | # To make fields retrieval more efficient, fetch all sub-fields of a | 1472 | # To make fields retrieval more efficient, fetch all sub-fields of a |
50 | 1473 | # given field at the same time. Because the order in the export list is | 1473 | # given field at the same time. Because the order in the export list is |
51 | 1474 | # arbitrary, this requires ordering all sub-fields of a given field | 1474 | # arbitrary, this requires ordering all sub-fields of a given field |
52 | 1475 | 1475 | ||
53 | === modified file 'addons/web/session.py' | |||
54 | --- addons/web/session.py 2012-12-17 10:01:27 +0000 | |||
55 | +++ addons/web/session.py 2012-12-27 07:46:22 +0000 | |||
56 | @@ -22,7 +22,7 @@ | |||
57 | 22 | def __init__(self, session, service_name): | 22 | def __init__(self, session, service_name): |
58 | 23 | self.session = session | 23 | self.session = session |
59 | 24 | self.service_name = service_name | 24 | self.service_name = service_name |
61 | 25 | 25 | ||
62 | 26 | def __getattr__(self, method): | 26 | def __getattr__(self, method): |
63 | 27 | def proxy_method(*args): | 27 | def proxy_method(*args): |
64 | 28 | result = self.session.send(self.service_name, method, *args) | 28 | result = self.session.send(self.service_name, method, *args) |
65 | @@ -60,7 +60,7 @@ | |||
66 | 60 | in a web session. | 60 | in a web session. |
67 | 61 | 61 | ||
68 | 62 | .. attribute:: context | 62 | .. attribute:: context |
70 | 63 | 63 | ||
71 | 64 | The session context, a ``dict``. Can be reloaded by calling | 64 | The session context, a ``dict``. Can be reloaded by calling |
72 | 65 | :meth:`openerpweb.openerpweb.OpenERPSession.get_context` | 65 | :meth:`openerpweb.openerpweb.OpenERPSession.get_context` |
73 | 66 | 66 | ||
74 | @@ -80,7 +80,7 @@ | |||
75 | 80 | self._suicide = False | 80 | self._suicide = False |
76 | 81 | self.context = {} | 81 | self.context = {} |
77 | 82 | self.jsonp_requests = {} # FIXME use a LRU | 82 | self.jsonp_requests = {} # FIXME use a LRU |
79 | 83 | 83 | ||
80 | 84 | def send(self, service_name, method, *args): | 84 | def send(self, service_name, method, *args): |
81 | 85 | code_string = "warning -- %s\n\n%s" | 85 | code_string = "warning -- %s\n\n%s" |
82 | 86 | try: | 86 | try: |
83 | @@ -112,7 +112,7 @@ | |||
84 | 112 | def authenticate(self, db, login, password, env=None): | 112 | def authenticate(self, db, login, password, env=None): |
85 | 113 | uid = self.proxy('common').authenticate(db, login, password, env) | 113 | uid = self.proxy('common').authenticate(db, login, password, env) |
86 | 114 | self.bind(db, uid, login, password) | 114 | self.bind(db, uid, login, password) |
88 | 115 | 115 | ||
89 | 116 | if uid: self.get_context() | 116 | if uid: self.get_context() |
90 | 117 | return uid | 117 | return uid |
91 | 118 | 118 | ||
92 | 119 | 119 | ||
93 | === modified file 'addons/web/static/src/js/corelib.js' | |||
94 | --- addons/web/static/src/js/corelib.js 2012-11-30 10:36:51 +0000 | |||
95 | +++ addons/web/static/src/js/corelib.js 2012-12-27 07:46:22 +0000 | |||
96 | @@ -1,16 +1,16 @@ | |||
97 | 1 | /* | 1 | /* |
98 | 2 | * Copyright (c) 2012, OpenERP S.A. | 2 | * Copyright (c) 2012, OpenERP S.A. |
99 | 3 | * All rights reserved. | 3 | * All rights reserved. |
101 | 4 | * | 4 | * |
102 | 5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
105 | 6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
106 | 7 | * | 7 | * |
107 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this | 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
109 | 9 | * list of conditions and the following disclaimer. | 9 | * list of conditions and the following disclaimer. |
110 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
111 | 11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
114 | 12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
115 | 13 | * | 13 | * |
116 | 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
117 | 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
118 | 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
119 | @@ -243,7 +243,7 @@ | |||
120 | 243 | 243 | ||
121 | 244 | /** | 244 | /** |
122 | 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. |
124 | 246 | * | 246 | * |
125 | 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, |
126 | 248 | * nor used directly. All integration with parenting and automatic unregistration of | 248 | * nor used directly. All integration with parenting and automatic unregistration of |
127 | 249 | * events is done in EventDispatcherMixin. | 249 | * events is done in EventDispatcherMixin. |
128 | @@ -303,7 +303,7 @@ | |||
129 | 303 | }); | 303 | }); |
130 | 304 | return lst; | 304 | return lst; |
131 | 305 | }, | 305 | }, |
133 | 306 | 306 | ||
134 | 307 | trigger : function(events) { | 307 | trigger : function(events) { |
135 | 308 | var event, node, calls, tail, args, all, rest; | 308 | var event, node, calls, tail, args, all, rest; |
136 | 309 | if (!(calls = this._callbacks)) | 309 | if (!(calls = this._callbacks)) |
137 | @@ -1043,7 +1043,7 @@ | |||
138 | 1043 | id: payload.id, | 1043 | id: payload.id, |
139 | 1044 | sid: this.httpsessionid, | 1044 | sid: this.httpsessionid, |
140 | 1045 | }; | 1045 | }; |
142 | 1046 | 1046 | ||
143 | 1047 | var set_sid = function (response, textStatus, jqXHR) { | 1047 | var set_sid = function (response, textStatus, jqXHR) { |
144 | 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... |
145 | 1049 | if (response.httpsessionid) { | 1049 | if (response.httpsessionid) { |
146 | @@ -1054,7 +1054,7 @@ | |||
147 | 1054 | url.url = this.url(url.url, null); | 1054 | url.url = this.url(url.url, null); |
148 | 1055 | var ajax = _.extend({ | 1055 | var ajax = _.extend({ |
149 | 1056 | type: "GET", | 1056 | type: "GET", |
151 | 1057 | dataType: 'jsonp', | 1057 | dataType: 'jsonp', |
152 | 1058 | jsonp: 'jsonp', | 1058 | jsonp: 'jsonp', |
153 | 1059 | cache: false, | 1059 | cache: false, |
154 | 1060 | data: data | 1060 | data: data |
155 | 1061 | 1061 | ||
156 | === modified file 'addons/web/static/src/js/coresetup.js' | |||
157 | --- addons/web/static/src/js/coresetup.js 2012-12-19 15:12:17 +0000 | |||
158 | +++ addons/web/static/src/js/coresetup.js 2012-12-27 07:46:22 +0000 | |||
159 | @@ -49,7 +49,6 @@ | |||
160 | 49 | _(this.module_list).each(function (mod) { | 49 | _(this.module_list).each(function (mod) { |
161 | 50 | self.module_loaded[mod] = true; | 50 | self.module_loaded[mod] = true; |
162 | 51 | }); | 51 | }); |
163 | 52 | this.context = {}; | ||
164 | 53 | this.active_id = null; | 52 | this.active_id = null; |
165 | 54 | return this.session_init(); | 53 | return this.session_init(); |
166 | 55 | }, | 54 | }, |
167 | @@ -67,7 +66,7 @@ | |||
168 | 67 | return deferred.then(function() { return self.load_modules(); }); | 66 | return deferred.then(function() { return self.load_modules(); }); |
169 | 68 | } | 67 | } |
170 | 69 | return $.when( | 68 | return $.when( |
172 | 70 | deferred, | 69 | deferred, |
173 | 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) { |
174 | 72 | instance.web._t.database.set_bundle(trans); | 71 | instance.web._t.database.set_bundle(trans); |
175 | 73 | }) | 72 | }) |
176 | @@ -86,13 +85,7 @@ | |||
177 | 86 | // If immediately follows a login (triggered by trying to restore | 85 | // If immediately follows a login (triggered by trying to restore |
178 | 87 | // an invalid session or no session at all), refresh session data | 86 | // an invalid session or no session at all), refresh session data |
179 | 88 | // (should not change, but just in case...) | 87 | // (should not change, but just in case...) |
187 | 89 | _.extend(self, { | 88 | _.extend(self, result); |
181 | 90 | session_id: result.session_id, | ||
182 | 91 | db: result.db, | ||
183 | 92 | username: result.login, | ||
184 | 93 | uid: result.uid, | ||
185 | 94 | user_context: result.context | ||
186 | 95 | }); | ||
188 | 96 | }); | 89 | }); |
189 | 97 | }, | 90 | }, |
190 | 98 | session_is_valid: function() { | 91 | session_is_valid: function() { |
191 | @@ -109,14 +102,7 @@ | |||
192 | 109 | if (!result.uid) { | 102 | if (!result.uid) { |
193 | 110 | return $.Deferred().reject(); | 103 | return $.Deferred().reject(); |
194 | 111 | } | 104 | } |
203 | 112 | 105 | _.extend(self, result); | |
196 | 113 | _.extend(self, { | ||
197 | 114 | session_id: result.session_id, | ||
198 | 115 | db: result.db, | ||
199 | 116 | username: result.login, | ||
200 | 117 | uid: result.uid, | ||
201 | 118 | user_context: result.context | ||
202 | 119 | }); | ||
204 | 120 | if (!_volatile) { | 106 | if (!_volatile) { |
205 | 121 | self.set_cookie('session_id', self.session_id); | 107 | self.set_cookie('session_id', self.session_id); |
206 | 122 | } | 108 | } |