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
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 messages = ir_translation.search_read([('module','in',mods),('lang','=',lang),
6 ('comments','like','openerp-web'),('value','!=',False),
7 ('value','!=','')],
8- ['module','src','value','lang'], order='module')
9+ ['module','src','value','lang'], order='module')
10 for mod, msg_group in itertools.groupby(messages, key=operator.itemgetter('module')):
11 translations_per_module.setdefault(mod,{'messages':[]})
12 translations_per_module[mod]['messages'].extend({'id': m['src'],
13@@ -797,9 +797,9 @@
14 return {
15 "session_id": req.session_id,
16 "uid": req.session._uid,
17- "context": req.session.get_context() if req.session._uid else {},
18+ "user_context": req.session.get_context() if req.session._uid else {},
19 "db": req.session._db,
20- "login": req.session._login,
21+ "username": req.session._login,
22 }
23
24 @openerpweb.jsonrequest
25@@ -1072,7 +1072,7 @@
26 @openerpweb.jsonrequest
27 def call(self, req, model, method, args, domain_id=None, context_id=None):
28 return self._call_kw(req, model, method, args, {})
29-
30+
31 @openerpweb.jsonrequest
32 def call_kw(self, req, model, method, args, kwargs):
33 return self._call_kw(req, model, method, args, kwargs)
34@@ -1186,7 +1186,7 @@
35 if width > 500: width = 500
36 if height > 500: height = 500
37 image_base64 = openerp.tools.image_resize_image(base64_source=image_base64, size=(width, height), encoding='base64', filetype='PNG')
38-
39+
40 image_data = base64.b64decode(image_base64)
41
42 except (TypeError, xmlrpclib.Fault):
43@@ -1468,7 +1468,7 @@
44 fields = self.fields_get(req, model)
45 if ".id" in export_fields:
46 fields['.id'] = fields.pop('id', {'string': 'ID'})
47-
48+
49 # To make fields retrieval more efficient, fetch all sub-fields of a
50 # given field at the same time. Because the order in the export list is
51 # arbitrary, this requires ordering all sub-fields of a given field
52
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 def __init__(self, session, service_name):
58 self.session = session
59 self.service_name = service_name
60-
61+
62 def __getattr__(self, method):
63 def proxy_method(*args):
64 result = self.session.send(self.service_name, method, *args)
65@@ -60,7 +60,7 @@
66 in a web session.
67
68 .. attribute:: context
69-
70+
71 The session context, a ``dict``. Can be reloaded by calling
72 :meth:`openerpweb.openerpweb.OpenERPSession.get_context`
73
74@@ -80,7 +80,7 @@
75 self._suicide = False
76 self.context = {}
77 self.jsonp_requests = {} # FIXME use a LRU
78-
79+
80 def send(self, service_name, method, *args):
81 code_string = "warning -- %s\n\n%s"
82 try:
83@@ -112,7 +112,7 @@
84 def authenticate(self, db, login, password, env=None):
85 uid = self.proxy('common').authenticate(db, login, password, env)
86 self.bind(db, uid, login, password)
87-
88+
89 if uid: self.get_context()
90 return uid
91
92
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 /*
98 * Copyright (c) 2012, OpenERP S.A.
99 * All rights reserved.
100- *
101+ *
102 * Redistribution and use in source and binary forms, with or without
103- * modification, are permitted provided that the following conditions are met:
104- *
105+ * modification, are permitted provided that the following conditions are met:
106+ *
107 * 1. Redistributions of source code must retain the above copyright notice, this
108- * list of conditions and the following disclaimer.
109+ * list of conditions and the following disclaimer.
110 * 2. Redistributions in binary form must reproduce the above copyright notice,
111 * this list of conditions and the following disclaimer in the documentation
112- * and/or other materials provided with the distribution.
113- *
114+ * and/or other materials provided with the distribution.
115+ *
116 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
117 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
118 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
119@@ -243,7 +243,7 @@
120
121 /**
122 * Backbone's events. Do not ever use it directly, use EventDispatcherMixin instead.
123- *
124+ *
125 * This class just handle the dispatching of events, it is not meant to be extended,
126 * nor used directly. All integration with parenting and automatic unregistration of
127 * events is done in EventDispatcherMixin.
128@@ -303,7 +303,7 @@
129 });
130 return lst;
131 },
132-
133+
134 trigger : function(events) {
135 var event, node, calls, tail, args, all, rest;
136 if (!(calls = this._callbacks))
137@@ -1043,7 +1043,7 @@
138 id: payload.id,
139 sid: this.httpsessionid,
140 };
141-
142+
143 var set_sid = function (response, textStatus, jqXHR) {
144 // If response give us the http session id, we store it for next requests...
145 if (response.httpsessionid) {
146@@ -1054,7 +1054,7 @@
147 url.url = this.url(url.url, null);
148 var ajax = _.extend({
149 type: "GET",
150- dataType: 'jsonp',
151+ dataType: 'jsonp',
152 jsonp: 'jsonp',
153 cache: false,
154 data: data
155
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 _(this.module_list).each(function (mod) {
161 self.module_loaded[mod] = true;
162 });
163- this.context = {};
164 this.active_id = null;
165 return this.session_init();
166 },
167@@ -67,7 +66,7 @@
168 return deferred.then(function() { return self.load_modules(); });
169 }
170 return $.when(
171- deferred,
172+ deferred,
173 self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).then(function(trans) {
174 instance.web._t.database.set_bundle(trans);
175 })
176@@ -86,13 +85,7 @@
177 // If immediately follows a login (triggered by trying to restore
178 // an invalid session or no session at all), refresh session data
179 // (should not change, but just in case...)
180- _.extend(self, {
181- session_id: result.session_id,
182- db: result.db,
183- username: result.login,
184- uid: result.uid,
185- user_context: result.context
186- });
187+ _.extend(self, result);
188 });
189 },
190 session_is_valid: function() {
191@@ -109,14 +102,7 @@
192 if (!result.uid) {
193 return $.Deferred().reject();
194 }
195-
196- _.extend(self, {
197- session_id: result.session_id,
198- db: result.db,
199- username: result.login,
200- uid: result.uid,
201- user_context: result.context
202- });
203+ _.extend(self, result);
204 if (!_volatile) {
205 self.set_cookie('session_id', self.session_id);
206 }