Skip to content
Permalink
Browse files

[FIX] web_editor: properly start website edit mode as restricted editor

It was impossible to open the website's edit mode as a user with
"restricted editor" permissions. The reason was that wysiwyg_multizone
was trying to manipulate data that is not injected into the html node
when `editable` is false (see `website.layout` template).
  • Loading branch information...
Zinston committed Mar 8, 2019
1 parent 6207391 commit 397248ed118f736151e9ba52554b033434167091
@@ -331,7 +331,7 @@ var WysiwygMultizone = Wysiwyg.extend({
var data = this._super();
var res_id = $editable.data('oe-id');
var res_model = $editable.data('oe-model');
if (!$editable.data('oe-model')) {
if (!$editable.data('oe-model') && $('html').data('editable')) {
var object = $('html').data('main-object');
res_model = object.split('(')[0];
res_id = +object.split('(')[1].split(',')[0];
@@ -0,0 +1,16 @@
odoo.define("website.tour.restricted_editor", function (require) {
"use strict";

var tour = require("web_tour.tour");

tour.register("restricted_editor", {
url: "/",
}, [{
trigger: 'a[data-action=edit]',
content: "Click \"EDIT\" button of website as Restricted Editor",
extra_trigger: ".homepage",
}, {
trigger: '#oe_snippets.o_loaded',
content: "Check that the snippets loaded properly",
}]);
});
@@ -46,3 +46,15 @@ def test_01_public_homepage(self):

def test_02_admin_tour_banner(self):
self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('banner')", "odoo.__DEBUG__.services['web_tour.tour'].tours.banner.ready", login='admin')

def test_03_restricted_editor(self):
self.restricted_editor = self.env['res.users'].create({
'name': 'Restricted Editor',
'login': 're',
'password': 're',
'groups_id': [(6, 0, [
self.ref('base.group_user'),
self.ref('website.group_website_publisher')
])]
})
self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('restricted_editor')", "odoo.__DEBUG__.services['web_tour.tour'].tours.restricted_editor.ready", login='re')
@@ -122,6 +122,7 @@

<script type="text/javascript" src="/website/static/src/js/tours/banner.js"/>
<script type="text/javascript" src="/website/static/src/js/tours/customize.js"/>
<script type="text/javascript" src="/website/static/src/js/tours/restricted_editor.js"/>
<script type="text/javascript" src="/website/static/src/js/tours/rte.js"/>

<script type="text/javascript" src="/website/static/src/js/widgets/ace.js"/>

0 comments on commit 397248e

Please sign in to comment.
You can’t perform that action at this time.