Merge lp:~deryck/launchpad/bug-page-distro-max-heat-532099 into lp:launchpad

Proposed by Deryck Hodge
Status: Merged
Approved by: Eleanor Berger
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~deryck/launchpad/bug-page-distro-max-heat-532099
Merge into: lp:launchpad
Diff against target: 55 lines (+34/-2)
2 files modified
lib/lp/bugs/browser/bugtask.py (+5/-1)
lib/lp/bugs/stories/bugs/xx-bug-heat-on-bug-page.txt (+29/-1)
To merge this branch: bzr merge lp:~deryck/launchpad/bug-page-distro-max-heat-532099
Reviewer Review Type Date Requested Status
Eleanor Berger (community) code Approve
Review via email: mp+21370@code.launchpad.net

Commit message

Use distribution context on bug page when displaying flame icons for packages.

Description of the change

This is a fix for bug 532099.

If a package has only a few bugs reported against it, then the bug page
for a bug with any heat at all will likely end up with four flame icons.
 This is a bit weird for two reasons -- the bug has a low heat value and
users clicking through from a distro bug page with see flame when there
wasn't in the bug list.

To fix this, we use the distro context on the bug page for packages.

A test has been update for this change. Run it with:

./bin/test -cvvt xx-bug-heat-on-bug-page.txt

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/bugs/stories/bugs/xx-bug-heat-on-bug-page.txt
  lib/lp/bugs/browser/bugtask.py

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/bugtask.py'
2--- lib/lp/bugs/browser/bugtask.py 2010-03-10 22:19:37 +0000
3+++ lib/lp/bugs/browser/bugtask.py 2010-03-15 18:02:26 +0000
4@@ -1083,7 +1083,11 @@
5 @property
6 def bug_heat_html(self):
7 """HTML representation of the bug heat."""
8- return bugtask_heat_html(self.context)
9+ if IDistributionSourcePackage.providedBy(self.context.target):
10+ return bugtask_heat_html(
11+ self.context, target=self.context.distribution)
12+ else:
13+ return bugtask_heat_html(self.context)
14
15
16 def calculate_heat_display(heat, max_bug_heat):
17
18=== modified file 'lib/lp/bugs/stories/bugs/xx-bug-heat-on-bug-page.txt'
19--- lib/lp/bugs/stories/bugs/xx-bug-heat-on-bug-page.txt 2010-02-25 19:49:02 +0000
20+++ lib/lp/bugs/stories/bugs/xx-bug-heat-on-bug-page.txt 2010-03-15 18:02:26 +0000
21@@ -3,5 +3,33 @@
22 The bug heat appears on the bug index page as four flames.
23
24 >>> anon_browser.open('http://bugs.launchpad.dev/firefox/+bug/1')
25- >>> print find_tag_by_id(anon_browser.contents, 'registration').fetch('img')[0]
26+ >>> print find_tag_by_id(
27+ ... anon_browser.contents, 'registration').fetch('img')[0]
28 <img src="/@@/bug-heat-0.png" alt="0 out of 4 heat flames" title="Heat: 0" />
29+
30+Packages use their distribution as context when generating flame icons
31+for a bug page, since a package of low heat value could be displayed
32+with four flames if there are few reported bugs against the package.
33+
34+ >>> from canonical.launchpad.ftests import login, logout
35+ >>> from canonical.launchpad.webapp import canonical_url
36+ >>> from lp.bugs.interfaces.bug import CreateBugParams
37+ >>> login('foo.bar@canonical.com')
38+ >>> max_heat = 5000.0
39+ >>> distro = factory.makeDistribution()
40+ >>> dsp = factory.makeDistributionSourcePackage(distribution=distro)
41+ >>> person = factory.makePerson()
42+ >>> bug_params = CreateBugParams(
43+ ... owner=person,
44+ ... title="A new bug",
45+ ... comment="This is a new bug")
46+ >>> dsp_bug = dsp.createBug(bug_params)
47+ >>> dsp_bug.setHeat(max_heat/4)
48+ >>> dsp.setMaxBugHeat(max_heat/4)
49+ >>> distro.setMaxBugHeat(max_heat)
50+ >>> logout()
51+
52+ >>> anon_browser.open(canonical_url(dsp_bug))
53+ >>> print find_tag_by_id(
54+ ... anon_browser.contents, 'registration').fetch('img')[0]
55+ <img src="/@@/bug-heat-0.png" alt="0 out of 4 heat flames" title="Heat: 1250" />