From: Mercurial C. <th...@in...> - 2015-06-21 19:20:24
|
# HG changeset patch # User Ralf Schlatterbeck <rs...@ru...> # Date 1434914410 -7200 # Node ID b562df8a505675b23707133c57dd2420ecc4a161 # Parent 03505579abef6e3eba3c6c99b27b69cc72915d1b 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. diff -r 03505579abef -r b562df8a5056 CHANGES.txt --- 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 diff -r 03505579abef -r b562df8a5056 roundup/cgi/actions.py --- 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) diff -r 03505579abef -r b562df8a5056 test/test_actions.py --- 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'}) |