From 8c666af35c9c7b79373b999d1df2d4ba350e8f5d Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Mar 2014 14:26:59 +0530 Subject: [IMP] remove menu_id from user model bzr revid: rajmyt@gmail.com-20140304085659-lufot16ae59y1jca --- addons/web/controllers/main.py | 9 --------- 1 file changed, 9 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index a9f56a2099c..d1e450cc34f 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1054,16 +1054,7 @@ class Menu(http.Controller): """ s = request.session Menus = s.model('ir.ui.menu') - # If a menu action is defined use its domain to get the root menu items - user_menu_id = s.model('res.users').read([s.uid], ['menu_id'], - request.context)[0]['menu_id'] - menu_domain = [('parent_id', '=', False)] - if user_menu_id: - domain_string = s.model('ir.actions.act_window').read( - [user_menu_id[0]], ['domain'],request.context)[0]['domain'] - if domain_string: - menu_domain = ast.literal_eval(domain_string) return Menus.search(menu_domain, 0, False, False, request.context) -- cgit v1.2.3 From 8e14e7a870b04345e7ae101910b1dc97c1865dca Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 9 Apr 2014 18:16:48 +0200 Subject: [WIP] AssetsBundle bzr revid: fme@openerp.com-20140409161648-sx87vc0saj30f68x --- addons/web/controllers/main.py | 52 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 2771c658270..4517c919b4c 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -31,6 +31,7 @@ except ImportError: import openerp import openerp.modules.registry +from openerp.addons.base.ir.ir_qweb import AssetsBundle from openerp.tools.translate import _ from openerp import http @@ -364,30 +365,17 @@ def manifest_glob(extension, addons=None, db=None, include_remotes=False): r.append((None, pattern)) else: for path in glob.glob(os.path.normpath(os.path.join(addons_path, addon, pattern))): - # Hack for IE, who limit 288Ko, 4095 rules, 31 sheets - # http://support.microsoft.com/kb/262161/en - if pattern == "static/lib/bootstrap/css/bootstrap.css": - if include_remotes: - r.insert(0, (None, fs2web(path[len(addons_path):]))) - else: - r.append((path, fs2web(path[len(addons_path):]))) + r.append((path, fs2web(path[len(addons_path):]))) return r -def manifest_list(extension, mods=None, db=None, debug=False): +def manifest_list(extension, mods=None, db=None, debug=None): """ list ressources to load specifying either: mods: a comma separated string listing modules db: a database name (return all installed modules in that database) """ + if debug is not None: + _logger.warning("openerp.addons.web.main.manifest_list(): debug parameter is deprecated") files = manifest_glob(extension, addons=mods, db=db, include_remotes=True) - if not debug: - path = '/web/webclient/' + extension - if mods is not None: - path += '?' + werkzeug.url_encode({'mods': mods}) - elif db: - path += '?' + werkzeug.url_encode({'db': db}) - - remotes = [wp for fp, wp in files if fp is None] - return [path] + remotes return [wp for _fp, wp in files] def get_last_modified(files): @@ -614,26 +602,16 @@ html_template = """ """ -def render_bootstrap_template(template, values=None, debug=False, db=None, **kw): - if not db: - db = request.db - if request.debug: - debug = True +def render_bootstrap_template(template, values=None, **kw): if values is None: - values = {} - values['debug'] = debug - values['current_db'] = db + values = dict() try: values['databases'] = http.db_list() except openerp.exceptions.AccessDenied: values['databases'] = None - for res in ['js', 'css']: - if res not in values: - values[res] = manifest_list(res, db=db, debug=debug) - if 'modules' not in values: - values['modules'] = module_boot(db=db) + values['modules'] = module_boot() values['modules'] = simplejson.dumps(values['modules']) return request.render(template, values, **kw) @@ -679,6 +657,20 @@ class Home(http.Controller): def login(self, db, login, key, redirect="/web", **kw): return login_and_redirect(db, login, key, redirect_url=redirect) + @http.route('/web/js/', type='http', auth="none") + def js_bundle(self, xmlid, **kw): + values = dict(manifest_list=manifest_list) + html = request.render(xmlid, lazy=False, qcontext=values) + bundle = AssetsBundle(xmlid, html) + return bundle.js() + + @http.route('/web/css/', type='http', auth='none') + def css_bundle(self, xmlid, **kw): + values = dict(manifest_list=manifest_list) + html = request.render(xmlid, lazy=False, qcontext=values) + bundle = AssetsBundle(xmlid, html) + return bundle.css() + class WebClient(http.Controller): @http.route('/web/webclient/csslist', type='json', auth="none") -- cgit v1.2.3 From c4c110c3c6445f2f5282de091475c357fee304e1 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 10 Apr 2014 12:18:16 +0200 Subject: [WIP] bundle css and js route bzr revid: fme@openerp.com-20140410101816-jg5pdlistgowu2zo --- addons/web/controllers/main.py | 57 ++---------------------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 4517c919b4c..983ba4c8b11 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -53,50 +53,6 @@ env.filters["json"] = simplejson.dumps # OpenERP Web helpers #---------------------------------------------------------- -def rjsmin(script): - """ Minify js with a clever regex. - Taken from http://opensource.perlig.de/rjsmin - Apache License, Version 2.0 """ - def subber(match): - """ Substitution callback """ - groups = match.groups() - return ( - groups[0] or - groups[1] or - groups[2] or - groups[3] or - (groups[4] and '\n') or - (groups[5] and ' ') or - (groups[6] and ' ') or - (groups[7] and ' ') or - '' - ) - - result = re.sub( - r'([^\047"/\000-\040]+)|((?:(?:\047[^\047\\\r\n]*(?:\\(?:[^\r\n]|\r?' - r'\n|\r)[^\047\\\r\n]*)*\047)|(?:"[^"\\\r\n]*(?:\\(?:[^\r\n]|\r?\n|' - r'\r)[^"\\\r\n]*)*"))[^\047"/\000-\040]*)|(?:(?<=[(,=:\[!&|?{};\r\n]' - r')(?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/' - r'))*((?:/(?![\r\n/*])[^/\\\[\r\n]*(?:(?:\\[^\r\n]|(?:\[[^\\\]\r\n]*' - r'(?:\\[^\r\n][^\\\]\r\n]*)*\]))[^/\\\[\r\n]*)*/)[^\047"/\000-\040]*' - r'))|(?:(?<=[\000-#%-,./:-@\[-^`{-~-]return)(?:[\000-\011\013\014\01' - r'6-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*((?:/(?![\r\n/*])[^/' - r'\\\[\r\n]*(?:(?:\\[^\r\n]|(?:\[[^\\\]\r\n]*(?:\\[^\r\n][^\\\]\r\n]' - r'*)*\]))[^/\\\[\r\n]*)*/)[^\047"/\000-\040]*))|(?<=[^\000-!#%&(*,./' - r':-@\[\\^`{|~])(?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/' - r'*][^*]*\*+)*/))*(?:((?:(?://[^\r\n]*)?[\r\n]))(?:[\000-\011\013\01' - r'4\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+(?=[^\000-\040"#' - r'%-\047)*,./:-@\\-^`|-~])|(?<=[^\000-#%-,./:-@\[-^`{-~-])((?:[\000-' - r'\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=[^' - r'\000-#%-,./:-@\[-^`{-~-])|(?<=\+)((?:[\000-\011\013\014\016-\040]|' - r'(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=\+)|(?<=-)((?:[\000-\011\0' - r'13\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=-)|(?:[\0' - r'00-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))+|(?:' - r'(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]|(?:/\*[^*' - r']*\*+(?:[^/*][^*]*\*+)*/))*)+', subber, '\n%s\n' % script - ).strip() - return result - db_list = http.db_list db_monodb = http.db_monodb @@ -333,15 +289,6 @@ def concat_files(file_list, reader=None, intersperse=""): concat_js_cache = {} -def concat_js(file_list): - content, checksum = concat_files(file_list, intersperse=';') - if checksum in concat_js_cache: - content = concat_js_cache[checksum] - else: - content = rjsmin(content) - concat_js_cache[checksum] = content - return content, checksum - def fs2web(path): """convert FS path into web path""" return '/'.join(path.split(os.path.sep)) @@ -662,14 +609,14 @@ class Home(http.Controller): values = dict(manifest_list=manifest_list) html = request.render(xmlid, lazy=False, qcontext=values) bundle = AssetsBundle(xmlid, html) - return bundle.js() + return request.make_response(bundle.js(), [('Content-Type', 'application/javascript')]) @http.route('/web/css/', type='http', auth='none') def css_bundle(self, xmlid, **kw): values = dict(manifest_list=manifest_list) html = request.render(xmlid, lazy=False, qcontext=values) bundle = AssetsBundle(xmlid, html) - return bundle.css() + return request.make_response(bundle.css(), [('Content-Type', 'text/css')]) class WebClient(http.Controller): -- cgit v1.2.3 From 26fd049ce09c9e301cafec5c5ad371b7aa6cb78f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 10 Apr 2014 16:32:12 +0200 Subject: [ADD] last modified date bzr revid: fme@openerp.com-20140410143212-p72kdj24293l577j --- addons/web/controllers/main.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 983ba4c8b11..e110c396427 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -606,16 +606,21 @@ class Home(http.Controller): @http.route('/web/js/', type='http', auth="none") def js_bundle(self, xmlid, **kw): - values = dict(manifest_list=manifest_list) - html = request.render(xmlid, lazy=False, qcontext=values) - bundle = AssetsBundle(xmlid, html) + values = dict(manifest_list=manifest_list) # manifest backward compatible mode, to be removed + assets_html = request.render(xmlid, lazy=False, qcontext=values) + bundle = AssetsBundle(xmlid, assets_html) + bundle.last_modified + if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: + return werkzeug.wrappers.Response(status=304) return request.make_response(bundle.js(), [('Content-Type', 'application/javascript')]) @http.route('/web/css/', type='http', auth='none') def css_bundle(self, xmlid, **kw): - values = dict(manifest_list=manifest_list) - html = request.render(xmlid, lazy=False, qcontext=values) - bundle = AssetsBundle(xmlid, html) + values = dict(manifest_list=manifest_list) # manifest backward compatible mode, to be removed + assets_html = request.render(xmlid, lazy=False, qcontext=values) + bundle = AssetsBundle(xmlid, assets_html) + if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: + return werkzeug.wrappers.Response(status=304) return request.make_response(bundle.css(), [('Content-Type', 'text/css')]) class WebClient(http.Controller): -- cgit v1.2.3 From 9d66f9bc6757131c23fba58f060cb7e1d693dda7 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 10 Apr 2014 17:54:22 +0200 Subject: [ADD] checksum bzr revid: fme@openerp.com-20140410155422-dr2rg5z9l255g9zn --- addons/web/controllers/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e110c396427..053abfe4cd2 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -612,7 +612,9 @@ class Home(http.Controller): bundle.last_modified if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: return werkzeug.wrappers.Response(status=304) - return request.make_response(bundle.js(), [('Content-Type', 'application/javascript')]) + return make_conditional( + request.make_response(bundle.js(), [('Content-Type', 'application/javascript')]), + bundle.last_modified, bundle.checksum) @http.route('/web/css/', type='http', auth='none') def css_bundle(self, xmlid, **kw): @@ -621,7 +623,9 @@ class Home(http.Controller): bundle = AssetsBundle(xmlid, assets_html) if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: return werkzeug.wrappers.Response(status=304) - return request.make_response(bundle.css(), [('Content-Type', 'text/css')]) + return make_conditional( + request.make_response(bundle.css(), [('Content-Type', 'text/css')]), + bundle.last_modified, bundle.checksum) class WebClient(http.Controller): -- cgit v1.2.3 From 1228cf5539b94f373543fe0822212340184000bd Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 10 Apr 2014 19:06:58 +0200 Subject: [REM] remove obsolete code bzr revid: fme@openerp.com-20140410170658-vrxzpya5p9ouafey --- addons/web/controllers/main.py | 94 ------------------------------------------ 1 file changed, 94 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 053abfe4cd2..dcbb7a80ef1 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -259,36 +259,6 @@ def concat_xml(file_list): root.append(child) return ElementTree.tostring(root, 'utf-8'), checksum.hexdigest() -def concat_files(file_list, reader=None, intersperse=""): - """ Concatenates contents of all provided files - - :param list(str) file_list: list of files to check - :param function reader: reading procedure for each file - :param str intersperse: string to intersperse between file contents - :returns: (concatenation_result, checksum) - :rtype: (str, str) - """ - checksum = hashlib.new('sha1') - if not file_list: - return '', checksum.hexdigest() - - if reader is None: - def reader(f): - import codecs - with codecs.open(f, 'rb', "utf-8-sig") as fp: - return fp.read().encode("utf-8") - - files_content = [] - for fname in file_list: - contents = reader(fname) - checksum.update(contents) - files_content.append(contents) - - files_concat = intersperse.join(files_content) - return files_concat, checksum.hexdigest() - -concat_js_cache = {} - def fs2web(path): """convert FS path into web path""" return '/'.join(path.split(os.path.sep)) @@ -641,70 +611,6 @@ class WebClient(http.Controller): def qweblist(self, mods=None): return manifest_list('qweb', mods=mods) - @http.route('/web/webclient/css', type='http', auth="none") - def css(self, mods=None, db=None): - files = list(manifest_glob('css', addons=mods, db=db)) - last_modified = get_last_modified(f[0] for f in files) - if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= last_modified: - return werkzeug.wrappers.Response(status=304) - - file_map = dict(files) - - rx_import = re.compile(r"""@import\s+('|")(?!'|"|/|https?://)""", re.U) - rx_url = re.compile(r"""url\s*\(\s*('|"|)(?!'|"|/|https?://|data:)""", re.U) - - def reader(f): - """read the a css file and absolutify all relative uris""" - with open(f, 'rb') as fp: - data = fp.read().decode('utf-8') - - path = file_map[f] - web_dir = os.path.dirname(path) - - data = re.sub( - rx_import, - r"""@import \1%s/""" % (web_dir,), - data, - ) - - data = re.sub( - rx_url, - r"url(\1%s/" % (web_dir,), - data, - ) - return data.encode('utf-8') - - content, checksum = concat_files((f[0] for f in files), reader) - - # move up all @import and @charset rules to the top - matches = [] - def push(matchobj): - matches.append(matchobj.group(0)) - return '' - - content = re.sub(re.compile("(@charset.+;$)", re.M), push, content) - content = re.sub(re.compile("(@import.+;$)", re.M), push, content) - - matches.append(content) - content = '\n'.join(matches) - - return make_conditional( - request.make_response(content, [('Content-Type', 'text/css')]), - last_modified, checksum) - - @http.route('/web/webclient/js', type='http', auth="none") - def js(self, mods=None, db=None): - files = [f[0] for f in manifest_glob('js', addons=mods, db=db)] - last_modified = get_last_modified(files) - if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= last_modified: - return werkzeug.wrappers.Response(status=304) - - content, checksum = concat_js(files) - - return make_conditional( - request.make_response(content, [('Content-Type', 'application/javascript')]), - last_modified, checksum) - @http.route('/web/webclient/qweb', type='http', auth="none") def qweb(self, mods=None, db=None): files = [f[0] for f in manifest_glob('qweb', addons=mods, db=db)] -- cgit v1.2.3 From 2b79294500cfef2a57d8fa4201e7a891406b7f9b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 10 Apr 2014 20:27:23 +0200 Subject: [ADD] cache bzr revid: fme@openerp.com-20140410182723-x1aoo2o0zhgkvwsf --- addons/web/controllers/main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6ef14d56f27..d8e4dd9d972 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -595,8 +595,15 @@ class Home(http.Controller): bundle.last_modified if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: return werkzeug.wrappers.Response(status=304) + headers = [('Content-Type', 'application/javascript')] + + if True: + # WIP: decide best cache settings + headers.append(('Cache-Control', 'max-age=%s' % (60*5))) + return request.make_response(bundle.js(), headers) + return make_conditional( - request.make_response(bundle.js(), [('Content-Type', 'application/javascript')]), + request.make_response(bundle.js(), headers), bundle.last_modified, bundle.checksum) @http.route('/web/css/', type='http', auth='none') @@ -606,8 +613,15 @@ class Home(http.Controller): bundle = AssetsBundle(xmlid, assets_html) if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: return werkzeug.wrappers.Response(status=304) + headers = [('Content-Type', 'text/css')] + + if True: + # WIP: decide best cache settings + headers.append(('Cache-Control', 'max-age=%s' % (60*5))) + return request.make_response(bundle.css(), headers) + return make_conditional( - request.make_response(bundle.css(), [('Content-Type', 'text/css')]), + request.make_response(bundle.css(), headers), bundle.last_modified, bundle.checksum) class WebClient(http.Controller): -- cgit v1.2.3 From fa20817cc3e5eb152924291cc7c5022f5a1b4e79 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 17 Apr 2014 12:47:32 +0200 Subject: [FIX] use of conditional responses in bundling bzr revid: xmo@openerp.com-20140417104732-6dkrxhsx7sha1347 --- addons/web/controllers/main.py | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index d8e4dd9d972..db4d56ef7ba 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -316,7 +316,7 @@ def get_last_modified(files): for f in files) return datetime.datetime(1970, 1, 1) -def make_conditional(response, last_modified=None, etag=None): +def make_conditional(response, last_modified=None, etag=None, max_age=0): """ Makes the provided response conditional based upon the request, and mandates revalidation from clients @@ -331,7 +331,7 @@ def make_conditional(response, last_modified=None, etag=None): :rtype: werkzeug.wrappers.Response """ response.cache_control.must_revalidate = True - response.cache_control.max_age = 0 + response.cache_control.max_age = max_age if last_modified: response.last_modified = last_modified if etag: @@ -589,40 +589,30 @@ class Home(http.Controller): @http.route('/web/js/', type='http', auth="none") def js_bundle(self, xmlid, **kw): - values = dict(manifest_list=manifest_list) # manifest backward compatible mode, to be removed + # manifest backward compatible mode, to be removed + values = {'manifest_list': manifest_list} assets_html = request.render(xmlid, lazy=False, qcontext=values) bundle = AssetsBundle(xmlid, assets_html) - bundle.last_modified - if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: - return werkzeug.wrappers.Response(status=304) - headers = [('Content-Type', 'application/javascript')] - if True: - # WIP: decide best cache settings - headers.append(('Cache-Control', 'max-age=%s' % (60*5))) - return request.make_response(bundle.js(), headers) + response = request.make_response( + bundle.js(), [('Content-Type', 'application/javascript')]) + # TODO: check that we don't do weird lazy overriding of __call__ which break body-removal return make_conditional( - request.make_response(bundle.js(), headers), - bundle.last_modified, bundle.checksum) + response, bundle.last_modified, bundle.checksum, max_age=60*5) @http.route('/web/css/', type='http', auth='none') def css_bundle(self, xmlid, **kw): - values = dict(manifest_list=manifest_list) # manifest backward compatible mode, to be removed + values = {'manifest_list': manifest_list} # manifest backward compatible mode, to be removed assets_html = request.render(xmlid, lazy=False, qcontext=values) bundle = AssetsBundle(xmlid, assets_html) - if request.httprequest.if_modified_since and request.httprequest.if_modified_since >= bundle.last_modified: - return werkzeug.wrappers.Response(status=304) - headers = [('Content-Type', 'text/css')] - if True: - # WIP: decide best cache settings - headers.append(('Cache-Control', 'max-age=%s' % (60*5))) - return request.make_response(bundle.css(), headers) + response = request.make_response( + bundle.css(), [('Content-Type', 'text/css')]) return make_conditional( - request.make_response(bundle.css(), headers), - bundle.last_modified, bundle.checksum) + response, bundle.last_modified, bundle.checksum, max_age=60*5) + class WebClient(http.Controller): -- cgit v1.2.3 From 8f00758d5167a823279ab4e2baff2e18d9647259 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 22 Apr 2014 13:16:31 +0200 Subject: [FIX] js and css route should be auth='user' bzr revid: fme@openerp.com-20140422111631-zpc46gzcn0s0jv6v --- addons/web/controllers/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index db4d56ef7ba..67b2428c5c4 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -587,12 +587,12 @@ class Home(http.Controller): def login(self, db, login, key, redirect="/web", **kw): return login_and_redirect(db, login, key, redirect_url=redirect) - @http.route('/web/js/', type='http', auth="none") + @http.route('/web/js/', type='http', auth="user") def js_bundle(self, xmlid, **kw): # manifest backward compatible mode, to be removed values = {'manifest_list': manifest_list} assets_html = request.render(xmlid, lazy=False, qcontext=values) - bundle = AssetsBundle(xmlid, assets_html) + bundle = AssetsBundle(xmlid, assets_html, debug=request.debug) response = request.make_response( bundle.js(), [('Content-Type', 'application/javascript')]) @@ -601,11 +601,11 @@ class Home(http.Controller): return make_conditional( response, bundle.last_modified, bundle.checksum, max_age=60*5) - @http.route('/web/css/', type='http', auth='none') + @http.route('/web/css/', type='http', auth='user') def css_bundle(self, xmlid, **kw): values = {'manifest_list': manifest_list} # manifest backward compatible mode, to be removed assets_html = request.render(xmlid, lazy=False, qcontext=values) - bundle = AssetsBundle(xmlid, assets_html) + bundle = AssetsBundle(xmlid, assets_html, debug=request.debug) response = request.make_response( bundle.css(), [('Content-Type', 'text/css')]) -- cgit v1.2.3 From 169ecc2b0127ad4c1e3b16d53d6186a917d3d7ab Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 22 Apr 2014 16:34:01 +0200 Subject: [FIX] js and css bundle controllers set as auth='public' bzr revid: fme@openerp.com-20140422143401-1jtxvd58mcw4kelw --- addons/web/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 67b2428c5c4..f0248530003 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -587,7 +587,7 @@ class Home(http.Controller): def login(self, db, login, key, redirect="/web", **kw): return login_and_redirect(db, login, key, redirect_url=redirect) - @http.route('/web/js/', type='http', auth="user") + @http.route('/web/js/', type='http', auth="public") def js_bundle(self, xmlid, **kw): # manifest backward compatible mode, to be removed values = {'manifest_list': manifest_list} @@ -601,7 +601,7 @@ class Home(http.Controller): return make_conditional( response, bundle.last_modified, bundle.checksum, max_age=60*5) - @http.route('/web/css/', type='http', auth='user') + @http.route('/web/css/', type='http', auth='public') def css_bundle(self, xmlid, **kw): values = {'manifest_list': manifest_list} # manifest backward compatible mode, to be removed assets_html = request.render(xmlid, lazy=False, qcontext=values) -- cgit v1.2.3 From bc1878e3e2d6bb8d76be6f02dfda0d844b5062c8 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 22 Apr 2014 16:41:32 +0200 Subject: [IMP] raise not found if bundle not found bzr revid: fme@openerp.com-20140422144132-thk3x58eqjvjzacu --- addons/web/controllers/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index f0248530003..51fd81a0881 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -31,7 +31,7 @@ except ImportError: import openerp import openerp.modules.registry -from openerp.addons.base.ir.ir_qweb import AssetsBundle +from openerp.addons.base.ir.ir_qweb import AssetsBundle, QWebTemplateNotFound from openerp.tools.translate import _ from openerp import http @@ -591,7 +591,10 @@ class Home(http.Controller): def js_bundle(self, xmlid, **kw): # manifest backward compatible mode, to be removed values = {'manifest_list': manifest_list} - assets_html = request.render(xmlid, lazy=False, qcontext=values) + try: + assets_html = request.render(xmlid, lazy=False, qcontext=values) + except QWebTemplateNotFound: + return request.not_found() bundle = AssetsBundle(xmlid, assets_html, debug=request.debug) response = request.make_response( @@ -604,7 +607,10 @@ class Home(http.Controller): @http.route('/web/css/', type='http', auth='public') def css_bundle(self, xmlid, **kw): values = {'manifest_list': manifest_list} # manifest backward compatible mode, to be removed - assets_html = request.render(xmlid, lazy=False, qcontext=values) + try: + assets_html = request.render(xmlid, lazy=False, qcontext=values) + except QWebTemplateNotFound: + return request.not_found() bundle = AssetsBundle(xmlid, assets_html, debug=request.debug) response = request.make_response( -- cgit v1.2.3 From 679d278d253e314e94da6e33c96a4f149f12fb6b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 23 Apr 2014 12:07:49 +0200 Subject: [FIX] /web/login restore request.uid in case of authentication failure bzr revid: fme@openerp.com-20140423100749-t4y4oi01tszn3z5a --- addons/web/controllers/main.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index f2101b27fd3..c98bce82259 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -682,9 +682,11 @@ class Home(http.Controller): redirect = '/web?' + request.httprequest.query_string values['redirect'] = redirect if request.httprequest.method == 'POST': + old_uid = request.uid uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password']) if uid is not False: return http.redirect_with_hash(redirect) + request.uid = old_uid values['error'] = "Wrong login/password" return render_bootstrap_template('web.login', values) -- cgit v1.2.3 From dde0c9324bda2aff24a832ace320f23379d1ad07 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 28 Apr 2014 20:24:51 +0200 Subject: [IMP] Convered qunit test suite to template bzr revid: fme@openerp.com-20140428182451-u4mgen9669gnldva --- addons/web/controllers/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index d56eecec53e..f85f8be49fe 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -619,7 +619,6 @@ class Home(http.Controller): return make_conditional( response, bundle.last_modified, bundle.checksum, max_age=60*5) - class WebClient(http.Controller): @http.route('/web/webclient/csslist', type='json', auth="none") @@ -707,6 +706,10 @@ class WebClient(http.Controller): def version_info(self): return openerp.service.common.exp_version() + @http.route('/web/tests', type='http', auth="none") + def index(self, mod=None, **kwargs): + return request.render('web.qunit_suite') + class Proxy(http.Controller): @http.route('/web/proxy/load', type='json', auth="none") -- cgit v1.2.3 From 556c1404c260a45bcbbc4e8f2f517ad20d5f702b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 30 Apr 2014 15:26:36 +0200 Subject: [FIX] backward compatibility for html_template bzr revid: fme@openerp.com-20140430132636-p42ehcb0dnc1d3jx --- addons/web/controllers/main.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index f85f8be49fe..a5fb1496ce9 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -508,6 +508,10 @@ html_template = """ OpenERP + + + + %(css)s %(js)s - %(css)s %(js)s ' % i for i in manifest_list('js', debug=request.debug)) - css = "\n ".join('' % i for i in manifest_list('css', debug=request.debug)) + css = """ + + + + + + + + + + + """ + js = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """ r = html_template % { 'js': js, -- cgit v1.2.3