Merge lp:~kfogel/launchpad/546943-really-hide-hidden-bug-comments into lp:launchpad

Proposed by Karl Fogel
Status: Merged
Approved by: Karl Fogel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~kfogel/launchpad/546943-really-hide-hidden-bug-comments
Merge into: lp:launchpad
Diff against target: 99 lines (+43/-7)
2 files modified
lib/lp/bugs/browser/bugtask.py (+6/-1)
lib/lp/bugs/stories/bugs/xx-bug-hidden-comments.txt (+37/-6)
To merge this branch: bzr merge lp:~kfogel/launchpad/546943-really-hide-hidden-bug-comments
Reviewer Review Type Date Requested Status
Deryck Hodge (community) code Approve
Abel Deuring Pending
Review via email: mp+22647@code.launchpad.net

Description of the change

Make sure that hidden (visible=false) comments cannot be reached via direct link either, except by admin.

To post a comment you must log in.
Revision history for this message
Deryck Hodge (deryck) wrote :

Looks good. Thanks!

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2010-03-29 13:31:23 +0000
+++ lib/lp/bugs/browser/bugtask.py 2010-04-01 18:39:29 +0000
@@ -485,7 +485,12 @@
485 # I have chosed to use this simple solution for now.485 # I have chosed to use this simple solution for now.
486 # -- kiko, 2006-07-11486 # -- kiko, 2006-07-11
487 try:487 try:
488 return comments[index]488 comment = comments[index]
489 if (comment.visible
490 or check_permission('launchpad.Admin', self.context)):
491 return comment
492 else:
493 return None
489 except IndexError:494 except IndexError:
490 return None495 return None
491496
492497
=== modified file 'lib/lp/bugs/stories/bugs/xx-bug-hidden-comments.txt'
--- lib/lp/bugs/stories/bugs/xx-bug-hidden-comments.txt 2009-08-28 14:31:15 +0000
+++ lib/lp/bugs/stories/bugs/xx-bug-hidden-comments.txt 2010-04-01 18:39:29 +0000
@@ -8,13 +8,13 @@
8 ... 'http://bugs.launchpad.dev'8 ... 'http://bugs.launchpad.dev'
9 ... '/jokosher/+bug/11')9 ... '/jokosher/+bug/11')
10 >>> user_browser.getControl(name='field.comment').value = (10 >>> user_browser.getControl(name='field.comment').value = (
11 ... 'This comment will not visible when the test completes.')11 ... 'This comment will not be visible when the test completes.')
12 >>> user_browser.getControl('Post Comment', index=-1).click()12 >>> user_browser.getControl('Post Comment', index=-1).click()
13 >>> main_content = find_main_content(user_browser.contents)13 >>> main_content = find_main_content(user_browser.contents)
14 >>> new_comment = main_content('div', 'boardCommentBody')[-1]14 >>> new_comment = main_content('div', 'boardCommentBody')[-1]
15 >>> new_comment_text = extract_text(new_comment.div)15 >>> new_comment_text = extract_text(new_comment.div)
16 >>> print new_comment_text16 >>> print new_comment_text
17 This comment will not visible when the test completes.17 This comment will not be visible when the test completes.
1818
19Admin users can set a message's visible attribute to False.19Admin users can set a message's visible attribute to False.
20In this case, the last message in the list, the one just added,20In this case, the last message in the list, the one just added,
@@ -26,7 +26,7 @@
26 >>> bug_11 = getUtility(IBugSet).get(11)26 >>> bug_11 = getUtility(IBugSet).get(11)
27 >>> message = bug_11.messages[-1]27 >>> message = bug_11.messages[-1]
28 >>> print message.text_contents28 >>> print message.text_contents
29 This comment will not visible when the test completes.29 This comment will not be visible when the test completes.
30 >>> bug_message = getUtility(IBugMessageSet).getByBugAndMessage(30 >>> bug_message = getUtility(IBugMessageSet).getByBugAndMessage(
31 ... bug_11, message)31 ... bug_11, message)
32 >>> bug_message.visible = False32 >>> bug_message.visible = False
@@ -46,7 +46,21 @@
46 This title, however, is the same as the bug title and so it will46 This title, however, is the same as the bug title and so it will
47 be suppressed in the UI.47 be suppressed in the UI.
4848
49For admin users, the message is still visible.49Ordinary users also cannot reach the message via direct link.
50
51 >>> comments = find_tags_by_class(
52 ... user_browser.contents, 'boardComment')
53 >>> for comment in comments:
54 ... number_node = comment.find(None, 'bug-comment-index')
55 ... latest_index = extract_text(number_node)
56 >>> user_browser.open(
57 ... 'http://bugs.launchpad.dev'
58 ... '/jokosher/+bug/11/comments/%d' % (int(latest_index[1:]) + 1))
59 Traceback (most recent call last):
60 ...
61 NotFound...
62
63For admin users, the message is still visible in the bug page.
5064
51 >>> admin_browser.open(65 >>> admin_browser.open(
52 ... 'http://bugs.launchpad.dev'66 ... 'http://bugs.launchpad.dev'
@@ -55,10 +69,27 @@
55 >>> last_comment = main_content('div', 'boardCommentBody')[-1]69 >>> last_comment = main_content('div', 'boardCommentBody')[-1]
56 >>> last_comment_text = extract_text(last_comment.div)70 >>> last_comment_text = extract_text(last_comment.div)
57 >>> print last_comment_text71 >>> print last_comment_text
58 This comment will not visible when the test completes.72 This comment will not be visible when the test completes.
5973
60Also, admin users will see the hidden message grayed out via an74Admin users will see the hidden message highlighted with an
61'adminHiddenComment' style.75'adminHiddenComment' style.
6276
63 >>> print last_comment.parent['class']77 >>> print last_comment.parent['class']
64 boardComment adminHiddenComment78 boardComment adminHiddenComment
79
80Admin users can also reach the message via direct link, and it is
81highlighted with the 'adminHiddenComment style there too.
82
83 >>> admin_browser.open(
84 ... 'http://bugs.launchpad.dev'
85 ... '/jokosher/+bug/11/comments/%d' % (int(latest_index[1:]) + 1))
86 >>> contents = extract_text(admin_browser.contents)
87 >>> print contents
88 Comment #7 : Bug #11 ...
89 This comment will not be visible when the test completes.
90 ...
91 >>> main_content = find_main_content(admin_browser.contents)
92 >>> last_comment = main_content('div', 'boardCommentBody')[-1]
93 >>> last_comment_text = extract_text(last_comment.div)
94 >>> print last_comment.parent['class']
95 boardComment adminHiddenComment