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