Merge lp:~kfogel/launchpad/78565-bug-comment-link-to-bug into lp:launchpad

Proposed by Karl Fogel
Status: Merged
Approved by: Eleanor Berger
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~kfogel/launchpad/78565-bug-comment-link-to-bug
Merge into: lp:launchpad
Diff against target: 123 lines (+57/-1)
5 files modified
lib/lp/bugs/browser/bugcomment.py (+12/-0)
lib/lp/bugs/browser/tests/test_breadcrumbs.py (+12/-0)
lib/lp/bugs/configure.zcml (+5/-0)
lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt (+1/-1)
lib/lp/testing/factory.py (+27/-0)
To merge this branch: bzr merge lp:~kfogel/launchpad/78565-bug-comment-link-to-bug
Reviewer Review Type Date Requested Status
Eleanor Berger (community) code Approve
Review via email: mp+21896@code.launchpad.net

Description of the change

When visiting a bug comment page, extend the breadcrumbs to include the comment and make the next rightmost item in the breadcrumbs (the parent bug's number) a link to the bug.

To post a comment you must log in.
Revision history for this message
Eleanor Berger (intellectronica) :
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/bugcomment.py'
2--- lib/lp/bugs/browser/bugcomment.py 2009-12-10 14:44:24 +0000
3+++ lib/lp/bugs/browser/bugcomment.py 2010-03-22 23:03:21 +0000
4@@ -10,6 +10,7 @@
5 'BugCommentBoxView',
6 'BugCommentBoxExpandedReplyView',
7 'BugCommentXHTMLRepresentation',
8+ 'BugMessageBreadcrumb',
9 'build_comments_from_chunks',
10 'should_display_remote_comments',
11 ]
12@@ -25,6 +26,7 @@
13 from canonical.launchpad.webapp import canonical_url, LaunchpadView
14 from canonical.launchpad.webapp.interfaces import ILaunchBag
15 from canonical.launchpad.webapp.authorization import check_permission
16+from canonical.launchpad.webapp.breadcrumb import Breadcrumb
17
18 from canonical.config import config
19
20@@ -253,3 +255,13 @@
21 (self.comment, self.request), name="+box")
22 return comment_view()
23
24+
25+class BugCommentBreadcrumb(Breadcrumb):
26+ """Breadcrumb for an `IBugComment`."""
27+
28+ def __init__(self, context):
29+ super(BugCommentBreadcrumb, self).__init__(context)
30+
31+ @property
32+ def text(self):
33+ return "Comment #%d" % self.context.index
34
35=== modified file 'lib/lp/bugs/browser/tests/test_breadcrumbs.py'
36--- lib/lp/bugs/browser/tests/test_breadcrumbs.py 2009-09-22 18:45:02 +0000
37+++ lib/lp/bugs/browser/tests/test_breadcrumbs.py 2010-03-22 23:03:21 +0000
38@@ -43,6 +43,18 @@
39 texts = self._getBreadcrumbsTexts(url, self.traversed_objects)
40 self.assertEquals(texts[-2], "Bug #%d" % self.bug.id)
41
42+ def test_bugtask_comment(self):
43+ login('foo.bar@canonical.com')
44+ comment = self.factory.makeBugComment(
45+ bug=self.bug, owner=self.bug.owner,
46+ subject="test comment subject", body="test comment body")
47+ url = canonical_url(comment, rootsite='bugs')
48+ urls = self._getBreadcrumbsURLs(url, self.traversed_objects)
49+ texts = self._getBreadcrumbsTexts(url, self.traversed_objects)
50+ self.assertEquals(url, "%s/comments/1" % self.bugtask_url)
51+ self.assertEquals(urls[-1], "%s" % self.bugtask_url)
52+ self.assertEquals(texts[-1], "Bug #%d" % self.bug.id)
53+
54 def test_bugtask_private_bug(self):
55 # A breadcrumb is not generated for a bug that the user does
56 # not have permission to view.
57
58=== modified file 'lib/lp/bugs/configure.zcml'
59--- lib/lp/bugs/configure.zcml 2010-03-08 13:51:22 +0000
60+++ lib/lp/bugs/configure.zcml 2010-03-22 23:03:21 +0000
61@@ -282,6 +282,11 @@
62 for="lp.bugs.interfaces.bugtask.IBugTask"
63 factory="lp.bugs.browser.bugtask.BugTaskBreadcrumb"
64 permission="zope.Public"/>
65+ <adapter
66+ provides="canonical.launchpad.webapp.interfaces.IBreadcrumb"
67+ for="lp.bugs.interfaces.bugmessage.IBugComment"
68+ factory="lp.bugs.browser.bugcomment.BugCommentBreadcrumb"
69+ permission="zope.Public"/>
70
71 <!-- NullBugTask -->
72
73
74=== modified file 'lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt'
75--- lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt 2009-09-23 14:40:53 +0000
76+++ lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt 2010-03-22 23:03:21 +0000
77@@ -53,7 +53,7 @@
78 The whole comment is visible on this page:
79
80 >>> print browser.title
81- Bug #2 (blackhole) : Bugs : Tomcat
82+ Comment #1 : Bug #2 (blackhole) : Bugs : Tomcat
83
84 >>> print_comments(browser.contents) #doctest: -ELLIPSIS
85 <div class="boardCommentBody">
86
87=== modified file 'lib/lp/testing/factory.py'
88--- lib/lp/testing/factory.py 2010-03-15 15:12:20 +0000
89+++ lib/lp/testing/factory.py 2010-03-22 23:03:21 +0000
90@@ -1212,6 +1212,33 @@
91 return getUtility(IBugWatchSet).createBugWatch(
92 bug, owner, bugtracker, str(remote_bug))
93
94+ def makeBugComment(self, bug=None, owner=None, subject=None, body=None):
95+ """Create and return a new bug comment.
96+
97+ :param bug: An `IBug` or a bug ID or name, or None, in which
98+ case a new bug is created.
99+ :param owner: An `IPerson`, or None, in which case a new
100+ person is created.
101+ :param subject: An `IMessage` or a string, or None, in which
102+ case a new message will be generated.
103+ :param body: An `IMessage` or a string, or None, in which
104+ case a new message will be generated.
105+ :return: An `IBugMessage`.
106+ """
107+ if bug is None:
108+ bug = self.makeBug()
109+ elif isinstance(bug, (int, long, basestring)):
110+ bug = getUtility(IBugSet).getByNameOrID(str(bug))
111+ if owner is None:
112+ owner = self.makePerson()
113+ if subject is None:
114+ subject = self.getUniqueString()
115+ if body is None:
116+ body = self.getUniqueString()
117+ return bug.newMessage(owner=owner, subject=subject,
118+ content=body, parent=None, bugwatch=None,
119+ remote_comment_id=None)
120+
121 def makeBugAttachment(self, bug=None, owner=None, data=None,
122 comment=None, filename=None, content_type=None,
123 description=None, is_patch=_DEFAULT):