You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/06/02 22:06:56 UTC
[05/39] allura git commit: [#1731] ticket:775 Don't show deleted
post/attachments in thread view
[#1731] ticket:775 Don't show deleted post/attachments in thread view
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/863ca87a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/863ca87a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/863ca87a
Branch: refs/heads/hs/7825
Commit: 863ca87a2cb336c795da3aa76bece248acbba3c7
Parents: 7b57bb6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 25 15:08:54 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 15:08:54 2015 +0000
----------------------------------------------------------------------
Allura/allura/controllers/attachments.py | 2 ++
Allura/allura/controllers/discuss.py | 2 ++
Allura/allura/tests/functional/test_discuss.py | 38 ++++++++++++++++++---
3 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/863ca87a/Allura/allura/controllers/attachments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/attachments.py b/Allura/allura/controllers/attachments.py
index a648873..c97a9d1 100644
--- a/Allura/allura/controllers/attachments.py
+++ b/Allura/allura/controllers/attachments.py
@@ -88,6 +88,8 @@ class AttachmentController(BaseController):
if request.method == 'POST':
self.handle_post(delete, **kw)
redirect(request.referer)
+ if self.artifact.deleted:
+ raise exc.HTTPNotFound
embed = False
if self.attachment.content_type and self.attachment.content_type.startswith('image/'):
embed = True
http://git-wip-us.apache.org/repos/asf/allura/blob/863ca87a/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index c7fe163..1fd24a0 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -307,6 +307,8 @@ class PostController(BaseController):
tags=['comment'])
redirect(request.referer)
elif request.method == 'GET':
+ if self.post.deleted:
+ raise exc.HTTPNotFound
if version is not None:
HC = self.post.__mongometa__.history_class
ss = HC.query.find(
http://git-wip-us.apache.org/repos/asf/allura/blob/863ca87a/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 cd30f44..0471b48 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -18,6 +18,8 @@
from mock import patch
from nose.tools import assert_in, assert_not_in, assert_equal
+from ming.odm import session
+
from allura.tests import TestController
from allura import model as M
@@ -227,6 +229,18 @@ class TestDiscuss(TestController):
assert 'Last edit: Test Admin less than 1 minute ago' in str(
r.html.find('div', {'class': 'display_post'}))
+ def test_deleted_post(self):
+ r = self._make_post('This is a post')
+ reply_form = r.html.find(
+ 'div', {'class': 'edit_post_form reply'}).find('form')
+ post_link = str(reply_form['action']).rstrip('/reply')
+ _, slug = post_link.rsplit('/', 1)
+ r = self.app.get(post_link, status=200)
+ post = M.Post.query.get(slug=slug)
+ post.deleted = True
+ session(post).flush(post)
+ r = self.app.get(post_link, status=404)
+
class TestAttachment(TestController):
@@ -254,17 +268,21 @@ class TestAttachment(TestController):
self.post_link = str(
r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
- def test_attach(self):
- r = self.app.post(self.post_link + 'attach',
- upload_files=[('file_info', 'test.txt', 'HiThere!')])
+ def attach_link(self):
r = self.app.get(self.thread_link)
for alink in r.html.findAll('a'):
if 'attachment' in alink['href']:
alink = str(alink['href'])
- break
+ return alink
else:
assert False, 'attachment link not found'
+
+ def test_attach(self):
+ r = self.app.post(self.post_link + 'attach',
+ upload_files=[('file_info', 'test.txt', 'HiThere!')])
+ r = self.app.get(self.thread_link)
assert '<div class="attachment_thumb">' in r
+ alink = self.attach_link()
r = self.app.get(alink)
assert r.content_disposition == 'attachment;filename="test.txt"', 'Attachments should force download'
r = self.app.post(self.post_link + 'attach',
@@ -289,3 +307,15 @@ class TestAttachment(TestController):
upload_files=[('file_info', 'test.txt', 'HiThere!')])
r = self.app.get(self.thread_link)
assert "test.txt" in r
+
+ def test_deleted_post_attachment(self):
+ self.app.post(
+ self.post_link + 'attach',
+ upload_files=[('file_info', 'test.txt', 'HiThere!')])
+ alink = self.attach_link()
+ r = self.app.get(alink, status=200)
+ _, slug = self.post_link.rstrip('/reply').rsplit('/', 1)
+ post = M.Post.query.get(slug=slug)
+ post.deleted = True
+ session(post).flush(post)
+ r = self.app.get(alink, status=404)