You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/03 23:57:48 UTC
[18/50] git commit: [#5891] ticket:316 add attachments to replies
[#5891] ticket:316 add attachments to replies
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/57d4e6fb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/57d4e6fb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/57d4e6fb
Branch: refs/heads/db/6007
Commit: 57d4e6fb9af1eabbf5cb16acbafbe0c00550db39
Parents: 5fb297e
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Mon Apr 22 14:25:23 2013 +0400
Committer: Yuriy Arhipov <yu...@yandex.ru>
Committed: Tue Apr 30 11:16:44 2013 +0400
----------------------------------------------------------------------
Allura/allura/controllers/discuss.py | 11 ++++++++++-
Allura/allura/tests/functional/test_discuss.py | 18 ++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/57d4e6fb/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 2ef1df4..b0bb426 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -344,11 +344,20 @@ class PostController(BaseController):
@validate(pass_validator, error_handler=index)
@utils.AntiSpam.validate('Spambot protection engaged')
@require_post(redir='.')
- def reply(self, **kw):
+ def reply(self, file_info=None, **kw):
require_access(self.thread, 'post')
kw = self.W.edit_post.to_python(kw, None)
p = self.thread.add_post(parent_id=self.post._id, **kw)
is_spam = g.spam_checker.check(kw['text'], artifact=p, user=c.user)
+ if hasattr(file_info, 'file'):
+ mime_type = file_info.type
+ if not mime_type or '/' not in mime_type:
+ mime_type = utils.guess_mime_type(file_info.filename)
+ p.attach(
+ file_info.filename, file_info.file, content_type=mime_type,
+ post_id=p._id,
+ thread_id=p.thread_id,
+ discussion_id=p.discussion_id)
redirect(request.referer)
@h.vardec
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/57d4e6fb/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 83910e9..633f078 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -220,3 +220,21 @@ class TestAttachment(TestController):
r = self.app.post(self.post_link + 'attach',
upload_files=[('file_info', 'test.o12', 'HiThere!')])
r = self.app.post(alink, params=dict(delete='on'))
+
+ @patch('allura.model.discuss.Post.notify')
+ def test_reply_attach(self, notify):
+ notify.return_value = True
+ r = self.app.get(self.thread_link)
+ post_form = r.html.find('form', {'action':self.post_link + 'reply'})
+ params = dict()
+ inputs = post_form.findAll('input')
+
+ for field in inputs:
+ if field.has_key('name') and (field['name']!='file_info'):
+ params[field['name']] = field.has_key('value') and field['value'] or ''
+ params[post_form.find('textarea')['name']] = 'Reply'
+ r = self.app.post(self.post_link + 'reply',
+ params=params,
+ upload_files=[('file_info', 'test.txt', 'HiThere!')])
+ r = self.app.get(self.thread_link)
+ assert "test.txt" in r