[IMP] distribute branding on @groups instead of disabling edition
Avoids 2 rendering passes, and allows editing e.g. events detail page, which couldn't be done (due to groups=public in a mail component) fixes #1994
This commit is contained in:
parent
31b58d553c
commit
7558e2e786
|
@ -125,7 +125,6 @@ class Report(osv.Model):
|
|||
user=user,
|
||||
res_company=user.company_id,
|
||||
website=website,
|
||||
editable_no_editor=_("The preferred way to edit a report is to use the HTML Editor"),
|
||||
)
|
||||
return view_obj.render(cr, uid, template, values, context=context)
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
<html t-att-lang="lang and lang.replace('_', '-')"
|
||||
t-att-data-website-id="website.id if editable and website else None"
|
||||
t-att-data-editable="'1' if editable else None"
|
||||
t-att-data-editable-no-editor="editable_no_editor or None"
|
||||
t-att-data-translatable="'1' if translatable else None"
|
||||
t-att-data-view-xmlid="xmlid if editable else None"
|
||||
t-att-data-main-object="repr(main_object) if editable else None"
|
||||
|
|
|
@ -257,12 +257,6 @@ class QWeb(orm.AbstractModel):
|
|||
uid = qwebcontext.get('request') and qwebcontext['request'].uid or None
|
||||
can_see = self.user_has_groups(cr, uid, groups=attribute_value) if cr and uid else False
|
||||
if not can_see:
|
||||
if qwebcontext.get('editable') and not qwebcontext.get('editable_no_editor'):
|
||||
errmsg = _("Editor disabled because some content can not be seen by a user who does not belong to the groups %s")
|
||||
raise openerp.http.Retry(
|
||||
_("User does not belong to groups %s") % attribute_value, {
|
||||
'editable_no_editor': errmsg % attribute_value
|
||||
})
|
||||
return ''
|
||||
|
||||
attribute_value = attribute_value.encode("utf8")
|
||||
|
@ -308,7 +302,7 @@ class QWeb(orm.AbstractModel):
|
|||
for current_node in element.iterchildren(tag=etree.Element):
|
||||
try:
|
||||
g_inner.append(self.render_node(current_node, qwebcontext))
|
||||
except (QWebException, openerp.http.Retry):
|
||||
except QWebException:
|
||||
raise
|
||||
except Exception:
|
||||
template = qwebcontext.get('__template__')
|
||||
|
|
|
@ -926,7 +926,7 @@ class view(osv.osv):
|
|||
:rtype: boolean
|
||||
"""
|
||||
return any(
|
||||
(attr == 'data-oe-model' or (attr != 't-field' and attr.startswith('t-')))
|
||||
(attr in ('data-oe-model', 'group') or (attr != 't-field' and attr.startswith('t-')))
|
||||
for attr in node.attrib
|
||||
)
|
||||
|
||||
|
|
|
@ -1096,15 +1096,6 @@ mimetypes.add_type('application/font-woff', '.woff')
|
|||
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
|
||||
mimetypes.add_type('application/x-font-ttf', '.ttf')
|
||||
|
||||
class Retry(RuntimeError):
|
||||
""" Exception raised during QWeb rendering to signal that the rendering
|
||||
should be retried with the provided ``render_updates`` dict merged into
|
||||
the previous rendering context
|
||||
"""
|
||||
def __init__(self, name, render_updates=None):
|
||||
super(Retry, self).__init__(name)
|
||||
self.updates = render_updates or {}
|
||||
|
||||
class Response(werkzeug.wrappers.Response):
|
||||
""" Response object passed through controller route chain.
|
||||
|
||||
|
@ -1154,13 +1145,9 @@ class Response(werkzeug.wrappers.Response):
|
|||
"""
|
||||
view_obj = request.registry["ir.ui.view"]
|
||||
uid = self.uid or request.uid or openerp.SUPERUSER_ID
|
||||
while True:
|
||||
try:
|
||||
return view_obj.render(
|
||||
request.cr, uid, self.template, self.qcontext,
|
||||
context=request.context)
|
||||
except Retry, e:
|
||||
self.qcontext.update(e.updates)
|
||||
return view_obj.render(
|
||||
request.cr, uid, self.template, self.qcontext,
|
||||
context=request.context)
|
||||
|
||||
def flatten(self):
|
||||
""" Forces the rendering of the response's template, sets the result
|
||||
|
|
Loading…
Reference in New Issue