From bbfae00dde9f5a953d5e84e6169d8eca7e1e1f50 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 13 Jan 2014 16:24:10 +0100 Subject: [PATCH 01/20] [FIX] remove Login usage from edi module bzr revid: fme@openerp.com-20140113152410-p32djnzq80xgh0o7 --- addons/edi/static/src/js/edi.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/edi/static/src/js/edi.js b/addons/edi/static/src/js/edi.js index 80002bd8743..91d2b842f8a 100644 --- a/addons/edi/static/src/js/edi.js +++ b/addons/edi/static/src/js/edi.js @@ -1,6 +1,7 @@ openerp.edi = function(instance) { var _t = instance.web._t; -instance.edi = {} +instance.edi = {}; + instance.edi.EdiImport = instance.web.Widget.extend({ @@ -10,11 +11,7 @@ instance.edi.EdiImport = instance.web.Widget.extend({ }, start: function() { if (!this.session.session_is_valid()) { - this.show_login(); - this.session.on_session_valid.add({ - callback: this.proxy('show_import'), - unique: true, - }); + instance.redirect('/web/login?redir=' + encodeURIComponent(window.location)); } else { this.show_import(); } @@ -25,12 +22,6 @@ instance.edi.EdiImport = instance.web.Widget.extend({ this.do_import(); }, - show_login: function() { - this.destroy_content(); - this.login = new instance.web.Login(this); - this.login.appendTo(this.$el); - }, - destroy_content: function() { _.each(_.clone(this.getChildren()), function(el) { el.destroy(); From 2c02157b7bf57bc4b01369323ff1630705781062 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 14 Jan 2014 10:08:19 +0100 Subject: [PATCH 02/20] [ADD] Comment some Login addons javascript until they are remade server side bzr revid: fme@openerp.com-20140114090819-vfswqeuqg2bg3ybu --- addons/auth_oauth/static/src/js/auth_oauth.js | 3 ++- addons/auth_oauth_signup/static/src/js/auth_oauth_signup.js | 2 ++ addons/auth_openid/static/src/js/auth_openid.js | 2 ++ addons/auth_signup/static/src/js/auth_signup.js | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/auth_oauth/static/src/js/auth_oauth.js b/addons/auth_oauth/static/src/js/auth_oauth.js index 5046469a5dc..a4295877e76 100644 --- a/addons/auth_oauth/static/src/js/auth_oauth.js +++ b/addons/auth_oauth/static/src/js/auth_oauth.js @@ -3,6 +3,7 @@ openerp.auth_oauth = function(instance) { _lt = instance.web._lt; var QWeb = instance.web.qweb; + /* TODO: make this a server side controller instance.web.Login.include({ start: function(parent, params) { var self = this; @@ -76,5 +77,5 @@ openerp.auth_oauth = function(instance) { }; }, }); - + */ }; diff --git a/addons/auth_oauth_signup/static/src/js/auth_oauth_signup.js b/addons/auth_oauth_signup/static/src/js/auth_oauth_signup.js index 6715943af9b..926fb607358 100644 --- a/addons/auth_oauth_signup/static/src/js/auth_oauth_signup.js +++ b/addons/auth_oauth_signup/static/src/js/auth_oauth_signup.js @@ -1,5 +1,6 @@ openerp.auth_oauth_signup = function(instance) { + /* TODO: make this a server side controller // override Login._oauth_state to add the signup token in the state instance.web.Login.include({ _oauth_state: function(provider) { @@ -10,5 +11,6 @@ openerp.auth_oauth_signup = function(instance) { return state; }, }); + */ }; diff --git a/addons/auth_openid/static/src/js/auth_openid.js b/addons/auth_openid/static/src/js/auth_openid.js index ac2804cb130..a96346f4699 100644 --- a/addons/auth_openid/static/src/js/auth_openid.js +++ b/addons/auth_openid/static/src/js/auth_openid.js @@ -3,6 +3,7 @@ openerp.auth_openid = function(instance) { var QWeb = instance.web.qweb; +/* TODO: make this a server side controller instance.web.Login = instance.web.Login.extend({ start: function() { var self = this; @@ -149,6 +150,7 @@ instance.web.Login = instance.web.Login.extend({ } }); +*/ }; diff --git a/addons/auth_signup/static/src/js/auth_signup.js b/addons/auth_signup/static/src/js/auth_signup.js index d9edb44d65f..d10f96316e2 100644 --- a/addons/auth_signup/static/src/js/auth_signup.js +++ b/addons/auth_signup/static/src/js/auth_signup.js @@ -2,6 +2,7 @@ openerp.auth_signup = function(instance) { instance.auth_signup = instance.auth_signup || {}; var _t = instance.web._t; + /* TODO: make this a server side controller instance.web.Login.include({ start: function() { var self = this; @@ -183,4 +184,5 @@ openerp.auth_signup = function(instance) { }); }, }); + */ }; From 1f916750eb79799d12c8a3d39dda502a0c6ae8f2 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 15 Jan 2014 15:09:58 +0100 Subject: [PATCH 03/20] [FIX] test_request: process cookies on redirections bzr revid: fme@openerp.com-20140115140958-9hm8thtlcnyflazz --- addons/website/tests/test_requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/tests/test_requests.py b/addons/website/tests/test_requests.py index fc56a93158c..e78c59a69cf 100644 --- a/addons/website/tests/test_requests.py +++ b/addons/website/tests/test_requests.py @@ -48,8 +48,8 @@ class CrawlSuite(unittest2.TestSuite): self.opener.add_handler(urllib2.UnknownHandler()) self.opener.add_handler(urllib2.HTTPHandler()) self.opener.add_handler(urllib2.HTTPSHandler()) - self.opener.add_handler(RedirectHandler()) self.opener.add_handler(urllib2.HTTPCookieProcessor()) + self.opener.add_handler(RedirectHandler()) self._authenticate(user, password) self.user = user From 96c79572f8ead79b5d8a762da6c6c17e5a78d8e8 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 15 Jan 2014 17:13:18 +0100 Subject: [PATCH 04/20] [FIX] test ui should use /login route for auto login bzr revid: fme@openerp.com-20140115161318-v8ksw0u0u1mpgn0x --- addons/website/tests/test_ui.py | 4 ++-- addons/website/tests/ui_suite/ui_test_runner.js | 7 ++++--- addons/website_blog/tests/test_ui.py | 4 ++-- addons/website_event/tests/test_ui.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 75a98869646..ffd5e738691 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -146,6 +146,6 @@ def full_path(filename): def load_tests(loader, base, _): base.addTest(WebsiteUiSuite(full_path('dummy_test.js'), {}, 5.0)) - base.addTest(WebsiteUiSuite(full_path('simple_dom_test.js'), { 'action': 'website.action_website_homepage' }, 60.0)) - base.addTest(WebsiteUiSuite(full_path('homepage_test.js'), { 'action': 'website.action_website_homepage' }, 60.0)) + base.addTest(WebsiteUiSuite(full_path('simple_dom_test.js'), {'redirect': '/page/website.homepage'}, 60.0)) + base.addTest(WebsiteUiSuite(full_path('homepage_test.js'), {'redirect': '/page/website.homepage'}, 60.0)) return base diff --git a/addons/website/tests/ui_suite/ui_test_runner.js b/addons/website/tests/ui_suite/ui_test_runner.js index ea8e03b36d3..acb67d387ad 100644 --- a/addons/website/tests/ui_suite/ui_test_runner.js +++ b/addons/website/tests/ui_suite/ui_test_runner.js @@ -27,15 +27,16 @@ function run (test) { var scheme = options.scheme ? options.scheme+'://' : 'http://'; var host = options.host ? options.host : 'localhost'; var port = options.port ? ':'+options.port : ''; - var path = options.path ? options.path : '/web'; + var path = options.path ? options.path : '/login'; var queryParams = []; if (options.db) queryParams.push('db='+options.db); + if (options.user) queryParams.push('login='+options.user); + if (options.password) queryParams.push('key='+options.password); + if (options.redirect) queryParams.push('redirect='+options.redirect); var query = queryParams.length > 0 ? '?'+queryParams.join('&') : ''; var hashParams = []; - if (options.user) hashParams.push('login='+options.user); - if (options.password) hashParams.push('password='+options.password); if (options.action) hashParams.push('action='+options.action); var hash = hashParams.length > 0 ? '#'+hashParams.join('&') : ''; diff --git a/addons/website_blog/tests/test_ui.py b/addons/website_blog/tests/test_ui.py index 0e57f94d931..f31b4378568 100644 --- a/addons/website_blog/tests/test_ui.py +++ b/addons/website_blog/tests/test_ui.py @@ -6,5 +6,5 @@ def full_path(filename): return os.path.join(os.path.join(os.path.dirname(__file__), 'ui_suite'), filename) def load_tests(loader, base, _): - base.addTest(test_ui.WebsiteUiSuite(full_path('post_test.js'), { 'action': 'website.action_website_homepage' }, 60.0)) - return base \ No newline at end of file + base.addTest(test_ui.WebsiteUiSuite(full_path('post_test.js'), {'redirect': '/page/website.homepage'}, 60.0)) + return base diff --git a/addons/website_event/tests/test_ui.py b/addons/website_event/tests/test_ui.py index 8c4bdb2a07c..eaf16ccc573 100644 --- a/addons/website_event/tests/test_ui.py +++ b/addons/website_event/tests/test_ui.py @@ -6,5 +6,5 @@ def full_path(filename): return os.path.join(os.path.join(os.path.dirname(__file__), 'ui_suite'), filename) def load_tests(loader, base, _): - base.addTest(test_ui.WebsiteUiSuite(full_path('event_test.js'), { 'action': 'website.action_website_homepage' }, 60.0)) - return base \ No newline at end of file + base.addTest(test_ui.WebsiteUiSuite(full_path('event_test.js'), {'redirect': '/page/website.homepage'}, 60.0)) + return base From 735c2b501b6c78ab6458e747a4bb436e74375989 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 16 Jan 2014 19:17:46 +0100 Subject: [PATCH 05/20] [IMP] integrate login into the website.layout bzr revid: fme@openerp.com-20140116181746-e2z9m4gym5kcdgmr --- addons/website/controllers/main.py | 10 +++++++++- addons/website/static/src/css/website.css | 6 +++++- addons/website/static/src/css/website.sass | 3 +++ addons/website/static/src/js/website.js | 2 +- addons/website/views/website_templates.xml | 8 +++++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 2ebdc2ba163..69b59acbfb3 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -20,7 +20,7 @@ import openerp from openerp.osv import fields from openerp.addons.website.models import website from openerp.addons.web import http -from openerp.addons.web.http import request +from openerp.addons.web.http import request, LazyResponse from ..utils import slugify @@ -41,6 +41,14 @@ class Website(openerp.addons.web.controllers.main.Home): pass return self.page("website.homepage") + @website.route('/web/login', type='http', auth="public", multilang=True) + def web_login(self, *args, **kw): + response = super(Website, self).web_login(*args, **kw) + if isinstance(response, LazyResponse): + values = dict(response.params['values'], disable_footer=True, redirect="/") + response = request.website.render(response.params['template'], values) + return response + @website.route('/pagenew/', type='http', auth="user") def pagenew(self, path, noredirect=NOPE): web = request.registry['website'] diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css index 095f9bec8bb..ae4e57ad942 100644 --- a/addons/website/static/src/css/website.css +++ b/addons/website/static/src/css/website.css @@ -1,4 +1,3 @@ -@charset "utf-8"; /* THIS CSS FILE IS FOR WEBSITE THEMING CUSTOMIZATION ONLY * * css for editor buttons, openerp widget included in the website and other @@ -479,3 +478,8 @@ span[data-oe-type="monetary"] { -o-column-count: 3; column-count: 3; } + +.oe_website_login_container { + width: 400px; + margin: 40px auto; +} diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass index 56257628a22..f801ad5456b 100644 --- a/addons/website/static/src/css/website.sass +++ b/addons/website/static/src/css/website.sass @@ -378,3 +378,6 @@ span[data-oe-type="monetary"] .oe_template_fallback @include column-count(3) +.oe_website_login_container + width: 400px + margin: 40px auto diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 64767d95171..7c153ada1a3 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -262,7 +262,7 @@ dom_ready.then(function () { /* ----- BOOTSTRAP STUFF ---- */ - $('.js_tooltip').bstooltip(); + // $('.js_tooltip').bstooltip(); /* ----- PUBLISHING STUFF ---- */ $(document).on('click', '.js_publish_management .js_publish_btn', function () { diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 9682d2f17e2..b1abb0922af 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -230,7 +230,13 @@ - +