# HG changeset patch # User Aurelien Campeas # Date 1378915445 -7200 # Node ID 549c999d06d27cbcbe8a4e2df0f8e4365886c2e7 # Parent 5a4fba9a02d78a8ef6c37cadccb2f61686e46927 [editcontroller] fix cardinality computation (closes #3120495) diff -r 5a4fba9a02d7 -r 549c999d06d2 web/test/unittest_views_basecontrollers.py --- a/web/test/unittest_views_basecontrollers.py Tue Jan 21 12:34:14 2014 +0100 +++ b/web/test/unittest_views_basecontrollers.py Wed Sep 11 18:04:05 2013 +0200 @@ -221,6 +221,21 @@ # created before. 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): req = self.request() peid = u(self.create_user(req, 'adim').eid) diff -r 5a4fba9a02d7 -r 549c999d06d2 web/views/editcontroller.py --- a/web/views/editcontroller.py Tue Jan 21 12:34:14 2014 +0100 +++ b/web/views/editcontroller.py Wed Sep 11 18:04:05 2013 +0200 @@ -158,7 +158,7 @@ # if cardinality is 1 and if the target entity is being # simultaneously edited, the current entity must be # created before the target one - if rdef.cardinality[0] == '1': + if rdef.cardinality[0 if role == 'subject' else 1] == '1': target_eid = values[param] if target_eid in values_by_eid: # add dependency from the target entity to the