From 871ccf70597f6a1b81c9f7d14917974cc78daa44 Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Mon, 14 Dec 2009 19:43:44 +0000 Subject: [PATCH] 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 --- CHANGES.txt | 5 ++++- roundup/cgi/actions.py | 6 +++--- test/test_actions.py | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) 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)) -- 2.30.2