changeset 4992:b562df8a5056

Fix form-parsing for multilinks If multiple new items are added to a multilink property, the old version would create the new items but only link one.
author Ralf Schlatterbeck <rsc@runtux.com>
date Sun, 21 Jun 2015 21:20:10 +0200
parents 03505579abef
children ae12b4b3ea9e
files CHANGES.txt roundup/cgi/actions.py test/test_actions.py
diffstat 3 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Sun Jun 21 20:55:21 2015 +0200
+++ b/CHANGES.txt	Sun Jun 21 21:20:10 2015 +0200
@@ -162,6 +162,9 @@
   Suggested by Karl-Philipp Richter. (Bernhard Reiter)
 - issue2550884 roundup-mailgw --help text improved to explain the allowed 
   parameters better. Suggested by by Karl-Philipp Richter. (Bernhard Reiter)
+- Fix form-parsing: If multiple new items are added to a multilink
+  property, the old version would create the new items but only link
+  one. (Ralf Schlatterbeck)
 
 
 2013-07-06: 1.5.0
--- a/roundup/cgi/actions.py	Sun Jun 21 20:55:21 2015 +0200
+++ b/roundup/cgi/actions.py	Sun Jun 21 21:20:10 2015 +0200
@@ -490,6 +490,8 @@
                                 props[linkprop] = existing
                             else:
                                 props[linkprop] = nodeid
+                    elif isinstance(propdef, hyperdb.Multilink):
+                        props[linkprop].append(nodeid)
 
         return '\n'.join(m)
 
--- a/test/test_actions.py	Sun Jun 21 20:55:21 2015 +0200
+++ b/test/test_actions.py	Sun Jun 21 21:20:10 2015 +0200
@@ -234,6 +234,7 @@
     def setUp(self):
         ActionTestCase.setUp(self)
         self.result = []
+        self.new_id = 16
         class AppendResult:
             def __init__(inner_self, name):
                 inner_self.name = name
@@ -241,7 +242,8 @@
                 self.result.append((inner_self.name, args, kw))
                 if inner_self.name == 'set':
                     return kw
-                return '17'
+                self.new_id+=1
+                return str(self.new_id)
 
         self.client.db.security.hasPermission = true
         self.client.classname = 'issue'
@@ -274,6 +276,24 @@
             pass
         self.assertEqual(expect, self.result)
 
+    def testMessageMultiAttach(self):
+        expect = \
+            [ ('create',(),{'content':'t2'})
+            , ('create',(),{'content':'t'})
+            , ('set',('4711',), {'messages':['23','42','17','18']})
+            ]
+        self.client.db.classes.get = lambda a, b:['23','42']
+        self.client.parsePropsFromForm = lambda: \
+            ( {('msg','-1'):{'content':'t'},('msg','-2'):{'content':'t2'}
+              , ('issue','4711'):{}}
+            , [('issue','4711','messages',[('msg','-1'),('msg','-2')])]
+            )
+        try :
+            self.action.handle()
+        except Redirect, msg:
+            pass
+        self.assertEqual(expect, self.result)
+
     def testFileAttach(self):
         expect = \
             [('create',(),{'content':'t','type':'text/plain','name':'t.txt'})

Roundup Issue Tracker: http://roundup-tracker.org/