From: schlatterbeck Date: Mon, 14 Dec 2009 19:43:44 +0000 (+0000) Subject: Fix linking of an existing item to a newly created item, e.g. edit X-Git-Url: https://git.tokkee.org/?p=roundup.git;a=commitdiff_plain;h=871ccf70597f6a1b81c9f7d14917974cc78daa44 Fix linking of an existing item to a newly created item, e.g. edit action in web template is name="issue-1@link@msg" value="msg1" would trigger a traceback about an unbound variable. Add new regression test for this case. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4408 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 4d08af6..7cafd2b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -36,7 +36,10 @@ Fixes: - Fix styling of calendar to make it more usable, fixes issue2550608 - Fix typo in email section of user guide, fixes issue2550607 - Fix WSGI response code (thanks Peter Pöml) - +- Fix linking of an existing item to a newly created item, e.g. + edit action in web template is name="issue-1@link@msg" value="msg1" + would trigger a traceback about an unbound variable. + Add new regression test for this case. 2009-10-09 1.4.10 (r4374) diff --git a/roundup/cgi/actions.py b/roundup/cgi/actions.py index 54af469..c198494 100755 --- a/roundup/cgi/actions.py +++ b/roundup/cgi/actions.py @@ -478,9 +478,9 @@ class EditCommon(Action): if linkid is None or linkid.startswith('-'): # linking to a new item if isinstance(propdef, hyperdb.Multilink): - props[linkprop] = [newid] + props[linkprop] = [nodeid] else: - props[linkprop] = newid + props[linkprop] = nodeid else: # linking to an existing item if isinstance(propdef, hyperdb.Multilink): @@ -488,7 +488,7 @@ class EditCommon(Action): existing.append(nodeid) props[linkprop] = existing else: - props[linkprop] = newid + props[linkprop] = nodeid return '
'.join(m) diff --git a/test/test_actions.py b/test/test_actions.py index 82fd6b4..edebe0c 100755 --- a/test/test_actions.py +++ b/test/test_actions.py @@ -249,6 +249,7 @@ class EditItemActionTestCase(ActionTestCase): ({'messages':hyperdb.Multilink('msg') ,'content':hyperdb.String() ,'files':hyperdb.Multilink('file') + ,'msg':hyperdb.Link('msg') }) self.action = EditItemAction(self.client) @@ -302,6 +303,19 @@ class EditItemActionTestCase(ActionTestCase): pass self.assertEqual(expect, self.result) + def testLinkNewToExisting(self): + expect = [('create',(),{'msg':'1','title':'TEST'})] + self.client.db.classes.get = lambda a, b:['23','42'] + self.client.parsePropsFromForm = lambda: \ + ( {('issue','-1'):{'title':'TEST'},('msg','1'):{}} + , [('issue','-1','msg',[('msg','1')])] + ) + try : + self.action.handle() + except Redirect, msg: + pass + self.assertEqual(expect, self.result) + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(RetireActionTestCase))