[web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
On AutomaticEntityForms, get_action used to bypass the logic from
FieldsForm.form_action() which handles the 'action' attribute itself,
preventing callers from overriding it at selection time. This capability
is used by the inlinedit cube.
In a nutshell, we let the deprecated AutomaticEntityForm.get_action()
raise an AttributeError, which allows FieldsForm.form_action() to handle
it properly.
--- a/web/test/unittest_views_editforms.py Fri Mar 06 16:17:11 2015 +0100
+++ b/web/test/unittest_views_editforms.py Tue Mar 10 11:52:04 2015 +0100
@@ -148,6 +148,13 @@
self.vreg['forms'].select('edition', req, entity=rset.get_entity(0, 0))
self.assertFalse(any(f for f in form.fields if f is None))
+ def test_edition_form_with_action(self):
+ with self.admin_access.web_request() as req:
+ rset = req.execute('CWUser X LIMIT 1')
+ form = self.vreg['forms'].select('edition', req, rset=rset, row=0,
+ col=0, action='my_custom_action')
+ self.assertEqual(form.form_action(), 'my_custom_action')
+
def test_attribute_add_permissions(self):
# https://www.cubicweb.org/ticket/4342844
with self.admin_access.repo_cnx() as cnx:
--- a/web/views/autoform.py Fri Mar 06 16:17:11 2015 +0100
+++ b/web/views/autoform.py Tue Mar 10 11:52:04 2015 +0100
@@ -732,10 +732,7 @@
@deprecated('[3.18] use form_action()')
def get_action(self):
- try:
- return self._action
- except AttributeError:
- return self._cw.build_url(self._default_form_action_path)
+ return self._action
@iclassmethod