Skip to content

Commit

Permalink
[FIX] website: 'Display Editor Bar on Website' group stopped working …
Browse files Browse the repository at this point in the history
…at commit a2ef044

The Edit button never appeared anymore for these users.
The idea was that they should see an edit button with
limited editing capabilities depending on their other
access rights.
For example, someone with only Sales Manager access and
'Display Editor Bar on Website'
would be able to edit online quotes from the website_quote
module, but not change the actual website pages or menus,
for instance.
  • Loading branch information
Gorash authored and odony committed Sep 26, 2014
1 parent dd2f229 commit 77c41cc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
5 changes: 4 additions & 1 deletion addons/website/models/ir_ui_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def render(self, cr, uid, id_or_xml_id, values=None, engine='ir.qweb', context=N
qcontext.update(values)

# in edit mode ir.ui.view will tag nodes
context = dict(context, inherit_branding=qcontext.get('editable', False))
if qcontext.get('editable'):
context = dict(context, inherit_branding=True)
elif request.registry['res.users'].has_group(cr, uid, 'base.group_website_publisher'):
context = dict(context, inherit_branding_auto=True)

view_obj = request.website.get_template(id_or_xml_id)
if 'main_object' not in qcontext:
Expand Down
10 changes: 1 addition & 9 deletions addons/website/static/src/js/website.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@

this.$('#website-top-edit').hide();
this.$('#website-top-view').show();
this.$buttons.edit.show();

var $edit_button = this.$buttons.edit
.prop('disabled', website.no_editor);
Expand Down Expand Up @@ -822,14 +821,7 @@
return $(root).find('[data-oe-model]')
.not('[data-oe-type = "selection"]')
.not('link, script')
.not('.oe_snippet_editor')
.filter(function () {
var $this = $(this);
// keep view sections and fields which are *not* in
// view sections for top-level editables
return $this.data('oe-model') === 'ir.ui.view'
|| !$this.closest('[data-oe-model = "ir.ui.view"]').length;
});
.not('.oe_snippet_editor');
},

_current_editor: function () {
Expand Down
5 changes: 3 additions & 2 deletions addons/website/static/src/js/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@
return templates_def;
}).then(function () {
// display button if they are at least one editable zone in the page (check the branding)
var editable = $('html').data('website-id') && !!$('[data-oe-model]').size();
$("#oe_editzone").toggle(editable);
if (!!$('[data-oe-model]').size()) {
$("#oe_editzone").show();
}

if ($('html').data('website-id')) {
website.id = $('html').data('website-id');
Expand Down
4 changes: 2 additions & 2 deletions addons/website/views/website_backend_navbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
</li>
</ul>

<ul id="oe_editzone" class="nav navbar-nav hidden-xs" style="padding-left: 20px;" groups="base.group_website_publisher">
<li><button type="button" data-action="edit" class="btn btn-primary btn-xs" style="display: none;">Edit</button></li>
<ul id="oe_editzone" class="nav navbar-nav hidden-xs" style="padding-left: 20px; display: none;" groups="base.group_website_publisher">
<li><button type="button" data-action="edit" class="btn btn-primary btn-xs">Edit</button></li>
</ul>

<ul id="oe_systray" class="nav navbar-nav navbar-right pull-right hidden-xs">
Expand Down
6 changes: 5 additions & 1 deletion openerp/addons/base/ir/ir_qweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,11 @@ def to_html(self, cr, uid, field_name, record, options,
field_name, record._name, exc_info=True)
content = None

if context and context.get('inherit_branding'):
inherit_branding = context and context.get('inherit_branding')
if not inherit_branding and context and context.get('inherit_branding_auto'):
inherit_branding = self.pool['ir.model.access'].check(cr, uid, record._name, 'write', False, context=context)

if inherit_branding:
# add branding attributes
g_att += ''.join(
' %s="%s"' % (name, escape(value))
Expand Down

0 comments on commit 77c41cc

Please sign in to comment.