Code

Fix linking of an existing item to a newly created item, e.g. edit
authorschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 14 Dec 2009 19:43:44 +0000 (19:43 +0000)
committerschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 14 Dec 2009 19:43:44 +0000 (19:43 +0000)
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
roundup/cgi/actions.py
test/test_actions.py

index 4d08af625838b6392e0c63c8d835019471ba3e8d..7cafd2b38f3334fb3e89fedfc65d761a20bbde1a 100644 (file)
@@ -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)
 
index 54af46911ad4fcb3d0953b6cf17542ed4462486b..c19849413aff73dc169ead6b0e6ba347f8996267 100755 (executable)
@@ -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 '<br>'.join(m)
 
index 82fd6b43cf6bbb54de6cb94396ee0f0d44f306de..edebe0c4a5d6d256a35dc930f8a4e84671373c4a 100755 (executable)
@@ -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))