Skip to content

Commit 19abbd4

Browse files
author
Ralf Schlatterbeck
committed
Bug-Fix: File attachments from the web-interface didn't work.
Added test for file attachments.
1 parent dbe007a commit 19abbd4

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

roundup/cgi/actions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.69 2007-05-09 06:18:52 schlatterbeck Exp $
1+
#$Id: actions.py,v 1.70 2007-05-15 16:23:39 schlatterbeck Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random, csv, codecs
44

@@ -367,7 +367,8 @@ def _editnodes(self, all_props, all_links):
367367
deps = {}
368368
links = {}
369369
for cn, nodeid, propname, vlist in all_links:
370-
if not (nodeid or all_props.has_key((cn, nodeid))):
370+
numeric_id = int (nodeid or 0)
371+
if not (numeric_id > 0 or all_props.has_key((cn, nodeid))):
371372
# link item to link to doesn't (and won't) exist
372373
continue
373374

test/test_actions.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ def __call__(inner_self, *args, **kw):
246246
self.client.db.classes.create = AppendResult('create')
247247
self.client.db.classes.set = AppendResult('set')
248248
self.client.db.classes.getprops = lambda: \
249-
({'messages':hyperdb.Multilink('msg'), 'content':hyperdb.String()})
249+
({'messages':hyperdb.Multilink('msg')
250+
,'content':hyperdb.String()
251+
,'files':hyperdb.Multilink('file')
252+
})
250253
self.action = EditItemAction(self.client)
251254

252255
def testMessageAttach(self):
@@ -265,6 +268,27 @@ def testMessageAttach(self):
265268
pass
266269
self.assertEqual(expect, self.result)
267270

271+
def testFileAttach(self):
272+
expect = \
273+
[('create',(),{'content':'t','type':'text/plain','name':'t.txt'})
274+
,('set',('4711',),{'files':['23','42','17']})
275+
]
276+
self.client.db.classes.get = lambda a, b:['23','42']
277+
self.client.parsePropsFromForm = lambda: \
278+
( {('file','-1'):{'content':'t','type':'text/plain','name':'t.txt'}
279+
,('issue','4711'):{}
280+
}
281+
, [('issue','4711','messages',[('msg','-1')])
282+
,('issue','4711','files',[('file','-1')])
283+
,('msg','-1','files',[('file','-1')])
284+
]
285+
)
286+
try :
287+
self.action.handle()
288+
except Redirect, msg:
289+
pass
290+
self.assertEqual(expect, self.result)
291+
268292
def testLinkExisting(self):
269293
expect = [('set',('4711',),{'messages':['23','42','1']})]
270294
self.client.db.classes.get = lambda a, b:['23','42']

0 commit comments

Comments
 (0)