Skip to content

Commit 2b38e65

Browse files
committed
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.
1 parent 44f0e4b commit 2b38e65

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ Fixed:
162162
Suggested by Karl-Philipp Richter. (Bernhard Reiter)
163163
- issue2550884 roundup-mailgw --help text improved to explain the allowed
164164
parameters better. Suggested by by Karl-Philipp Richter. (Bernhard Reiter)
165+
- Fix form-parsing: If multiple new items are added to a multilink
166+
property, the old version would create the new items but only link
167+
one. (Ralf Schlatterbeck)
165168

166169

167170
2013-07-06: 1.5.0

roundup/cgi/actions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ def _editnodes(self, all_props, all_links):
490490
props[linkprop] = existing
491491
else:
492492
props[linkprop] = nodeid
493+
elif isinstance(propdef, hyperdb.Multilink):
494+
props[linkprop].append(nodeid)
493495

494496
return '\n'.join(m)
495497

test/test_actions.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,16 @@ class EditItemActionTestCase(ActionTestCase):
234234
def setUp(self):
235235
ActionTestCase.setUp(self)
236236
self.result = []
237+
self.new_id = 16
237238
class AppendResult:
238239
def __init__(inner_self, name):
239240
inner_self.name = name
240241
def __call__(inner_self, *args, **kw):
241242
self.result.append((inner_self.name, args, kw))
242243
if inner_self.name == 'set':
243244
return kw
244-
return '17'
245+
self.new_id+=1
246+
return str(self.new_id)
245247

246248
self.client.db.security.hasPermission = true
247249
self.client.classname = 'issue'
@@ -274,6 +276,24 @@ def testMessageAttach(self):
274276
pass
275277
self.assertEqual(expect, self.result)
276278

279+
def testMessageMultiAttach(self):
280+
expect = \
281+
[ ('create',(),{'content':'t2'})
282+
, ('create',(),{'content':'t'})
283+
, ('set',('4711',), {'messages':['23','42','17','18']})
284+
]
285+
self.client.db.classes.get = lambda a, b:['23','42']
286+
self.client.parsePropsFromForm = lambda: \
287+
( {('msg','-1'):{'content':'t'},('msg','-2'):{'content':'t2'}
288+
, ('issue','4711'):{}}
289+
, [('issue','4711','messages',[('msg','-1'),('msg','-2')])]
290+
)
291+
try :
292+
self.action.handle()
293+
except Redirect, msg:
294+
pass
295+
self.assertEqual(expect, self.result)
296+
277297
def testFileAttach(self):
278298
expect = \
279299
[('create',(),{'content':'t','type':'text/plain','name':'t.txt'})

0 commit comments

Comments
 (0)