Commit 1b4c0274 authored by Aurelien Campeas's avatar Aurelien Campeas
Browse files

[editcontroller] fix cardinality computation (closes #3120495)

parent 5a4fba9a02d7
...@@ -221,6 +221,21 @@ class EditControllerTC(CubicWebTC): ...@@ -221,6 +221,21 @@ class EditControllerTC(CubicWebTC):
# created before. # created before.
self.assertGreater(salesterm.eid, salesterm.described_by_test[0].eid) self.assertGreater(salesterm.eid, salesterm.described_by_test[0].eid)
def test_edit_mandatory_inlined3_object(self):
# non regression test for #3120495. Without the fix, leads to
# "unhashable type: 'list'" error
req = self.request()
cwrelation = u(req.execute('CWEType X WHERE X name "CWSource"')[0][0])
req.form = {'eid': [cwrelation], '__maineid' : cwrelation,
'__type:'+cwrelation: 'CWEType',
'_cw_entity_fields:'+cwrelation: 'to_entity-object',
'to_entity-object:'+cwrelation: [9999, 9998],
}
with self.session.deny_all_hooks_but():
path, params = self.expect_redirect_handle_request(req, 'edit')
self.assertTrue(path.startswith('cwetype/CWSource'), path)
def test_edit_multiple_linked(self): def test_edit_multiple_linked(self):
req = self.request() req = self.request()
peid = u(self.create_user(req, 'adim').eid) peid = u(self.create_user(req, 'adim').eid)
......
...@@ -158,7 +158,7 @@ class EditController(basecontrollers.ViewController): ...@@ -158,7 +158,7 @@ class EditController(basecontrollers.ViewController):
# if cardinality is 1 and if the target entity is being # if cardinality is 1 and if the target entity is being
# simultaneously edited, the current entity must be # simultaneously edited, the current entity must be
# created before the target one # created before the target one
if rdef.cardinality[0] == '1': if rdef.cardinality[0 if role == 'subject' else 1] == '1':
target_eid = values[param] target_eid = values[param]
if target_eid in values_by_eid: if target_eid in values_by_eid:
# add dependency from the target entity to the # add dependency from the target entity to the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment