[web] consider inlined relations in has_editable_relation. Closes #3049970
In some cases where the user can only add/edit inlined relations (though
actually edit perms of the inlined relation doesn't seem checked), the "modify"
action doesn't appear while it should.
--- a/web/test/unittest_views_actions.py Mon Jul 29 16:00:40 2013 +0200
+++ b/web/test/unittest_views_actions.py Mon Jul 29 16:01:18 2013 +0200
@@ -19,6 +19,7 @@
from logilab.common.testlib import unittest_main
from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.web.views import actions, uicfg
class ActionsTC(CubicWebTC):
def test_view_action(self):
@@ -28,6 +29,18 @@
vaction = [action for action in actions if action.__regid__ == 'view'][0]
self.assertEqual(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X')
+ def test_has_editable_relations(self):
+ """ensure has_editable_relation predicate used by ModifyAction
+ return positive score if there is only some inlined forms
+ """
+ use_email = self.schema['use_email'].rdefs['CWUser', 'EmailAddress']
+ with self.temporary_permissions((use_email, {'add': ('guests',)}),
+ ):
+ with self.login('anon'):
+ req = self.request()
+ predicate = actions.has_editable_relation()
+ self.assertEqual(predicate(None, req, rset=req.user.as_rset()),
+ 1)
if __name__ == '__main__':
unittest_main()
--- a/web/views/actions.py Mon Jul 29 16:00:40 2013 +0200
+++ b/web/views/actions.py Mon Jul 29 16:01:18 2013 +0200
@@ -50,8 +50,9 @@
entity=entity, mainform=False)
for dummy in form.editable_relations():
return 1
- editableattrs = form.editable_attributes(strict=True)
- for rschema, role in editableattrs:
+ for dummy in form.inlined_relations():
+ return 1
+ for dummy in form.editable_attributes(strict=True):
return 1
return 0