Merge lp:~cjwatson/launchpad/testfix-unhide-comments into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17739
Proposed branch: lp:~cjwatson/launchpad/testfix-unhide-comments
Merge into: lp:launchpad
Diff against target: 34 lines (+10/-2)
1 file modified
lib/lp/bugs/browser/bugtask.py (+10/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/testfix-unhide-comments
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+271043@code.launchpad.net

Commit message

Make direct links to hidden comments work for their owners.

Description of the change

Make direct links to hidden comments work for their owners. Fixes xx-bug-hidden-comments test failure.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtask.py'
2--- lib/lp/bugs/browser/bugtask.py 2015-09-14 15:56:21 +0000
3+++ lib/lp/bugs/browser/bugtask.py 2015-09-14 23:53:13 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """IBugTask-related browser views."""
10@@ -292,6 +292,9 @@
11 # cannot see, because they have been marked invisible.
12 strip_invisible = True
13 if user is not None:
14+ # XXX cjwatson 2015-09-15: Unify with
15+ # Bug.userCanSetCommentVisibility, which also allows
16+ # project-privileged users.
17 role = PersonRoles(user)
18 strip_invisible = not (role.in_admin or role.in_registry_experts)
19 if strip_invisible:
20@@ -383,9 +386,14 @@
21 # Ask the DB to slice out just the comment that we need.
22 comments = get_comments_for_bugtask(
23 self.context, slice_info=[slice(index, index + 1)])
24+ # XXX cjwatson 2015-09-15: Unify with
25+ # Bug.userCanSetCommentVisibility, which also allows
26+ # project-privileged users.
27+ role = PersonRoles(getUtility(ILaunchBag).user)
28 if (comments and
29 (comments[0].visible
30- or check_permission('launchpad.Admin', self.context))):
31+ or comments[0].owner == getUtility(ILaunchBag).user
32+ or role.in_admin or role.in_registry_experts)):
33 return comments[0]
34 return None
35