Merge lp:~adeuring/launchpad/bug-829074-ui into lp:launchpad

Proposed by Abel Deuring
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 14755
Proposed branch: lp:~adeuring/launchpad/bug-829074-ui
Merge into: lp:launchpad
Diff against target: 184 lines (+91/-17)
4 files modified
lib/lp/bugs/browser/bugtask.py (+22/-8)
lib/lp/bugs/browser/tests/test_buglisting.py (+31/-0)
lib/lp/bugs/interfaces/bugtask.py (+3/-0)
lib/lp/bugs/templates/bugtask-macros-tableview.pt (+35/-9)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-829074-ui
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+91796@code.launchpad.net

Commit message

[r=gmb][bug=829074] new properties BugTaskSearchListingView.upstream_project and IBugTaskSearch.upstream_target; UI elements to select an upstream project in 'Advanced Search' pages.

Description of the change

This branch fixes bug 829074: Show bugs that are not known to affect
"official" upstream

The already merged branch lp:~adeuring/launchpad/bug-829074 has the
required changes for BugTaskSet.searchTasks(); this branch adds a
minimal set of UI changes: It allows only to select the project
that is linked to a source package via the Packaging table.

I'll extend this quite simple and "narrow" interpretation of
"possibly relevant upstream" in a later branch so that users
can select a arbitrary project, or an upstream SP or DSP. The latter
can be useful when the Ubuntu upstream is not a project but
a Debian package. This should also address the quite similar
bug 232545.

The changes are straightforward:

- A new property BugTaskSearchListingView.upstream_project, which is
  the Product linked via the packaging table if the current context
  is an SP or DSP.

- A new element in the schema used by BugTaskSearchListingView:
  IBugTaskSearch.upstream_target

- new UI elements in the page template.

tests:
./bin/test -vvt lp.bugs.browser.tests.test_buglisting.*test_package
./bin/test -vvt lp.bugs.browser.tests.test_buglisting.*test_upstream_project
./bin/test -vvt lp.bugs.browser.tests.test_buglisting.*test_filter_by_upstream

(I did not add any tests that selecting the upstream project returns the
desired search results -- this is already covered in
lp:~adeuring/launchpad/bug-829074 . But test_filter_by_upstream_target()
ensures that the form parameter field.upstream_target is correctly
"mapped" to BugTaskSearchParams.upstream_target.)

No lint

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
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 2012-01-25 05:34:12 +0000
3+++ lib/lp/bugs/browser/bugtask.py 2012-02-07 11:04:19 +0000
4@@ -2630,14 +2630,13 @@
5 else:
6 return 'None specified'
7
8- @property
9- def upstream_launchpad_project(self):
10+ @cachedproperty
11+ def upstream_project(self):
12 """The linked upstream `IProduct` for the package.
13
14 If this `IBugTarget` is a `IDistributionSourcePackage` or an
15- `ISourcePackage` and it is linked to an upstream project that uses
16- Launchpad to track bugs, return the `IProduct`. Otherwise,
17- return None
18+ `ISourcePackage` and it is linked to an upstream project, return
19+ the `IProduct`. Otherwise, return None
20
21 :returns: `IProduct` or None
22 """
23@@ -2650,9 +2649,24 @@
24 if sp is not None:
25 packaging = sp.packaging
26 if packaging is not None:
27- product = packaging.productseries.product
28- if product.bug_tracking_usage == ServiceUsage.LAUNCHPAD:
29- return product
30+ return packaging.productseries.product
31+ return None
32+
33+ @cachedproperty
34+ def upstream_launchpad_project(self):
35+ """The linked upstream `IProduct` for the package.
36+
37+ If this `IBugTarget` is a `IDistributionSourcePackage` or an
38+ `ISourcePackage` and it is linked to an upstream project that uses
39+ Launchpad to track bugs, return the `IProduct`. Otherwise,
40+ return None
41+
42+ :returns: `IProduct` or None
43+ """
44+ product = self.upstream_project
45+ if (product is not None and
46+ product.bug_tracking_usage == ServiceUsage.LAUNCHPAD):
47+ return product
48 return None
49
50 @property
51
52=== modified file 'lib/lp/bugs/browser/tests/test_buglisting.py'
53--- lib/lp/bugs/browser/tests/test_buglisting.py 2012-01-01 02:58:52 +0000
54+++ lib/lp/bugs/browser/tests/test_buglisting.py 2012-02-07 11:04:19 +0000
55@@ -467,6 +467,18 @@
56 bug_target, rootsite='answers', view_name='+addquestion')
57 self.assertEqual(url, view.addquestion_url)
58
59+ def test_upstream_project(self):
60+ # BugTaskSearchListingView.upstream_project and
61+ # BugTaskSearchListingView.upstream_launchpad_project are
62+ # None for all bug targets except SourcePackages
63+ # and DistributionSourcePackages.
64+ bug_target = self._makeBugTargetProduct(
65+ bug_tracker='launchpad', packaging=True)
66+ view = create_initialized_view(
67+ bug_target, '+bugs', principal=bug_target.owner)
68+ self.assertIs(None, view.upstream_project)
69+ self.assertIs(None, view.upstream_launchpad_project)
70+
71
72 class TestBugTaskSearchListingViewDSP(BugTargetTestCase):
73
74@@ -489,6 +501,7 @@
75 view = create_initialized_view(
76 bug_target, '+bugs', principal=upstream_project.owner)
77 self.assertEqual(upstream_project, view.upstream_launchpad_project)
78+ self.assertEqual(upstream_project, view.upstream_project)
79 content = find_tag_by_id(view.render(), 'also-in-upstream')
80 link = canonical_url(upstream_project, rootsite='bugs')
81 self.assertEqual(link, content.a['href'])
82@@ -501,6 +514,7 @@
83 view = create_initialized_view(
84 bug_target, '+bugs', principal=upstream_project.owner)
85 self.assertEqual(None, view.upstream_launchpad_project)
86+ self.assertEqual(upstream_project, view.upstream_project)
87 self.assertEqual(None, find_tag_by_id(view(), 'also-in-upstream'))
88
89 def test_package_without_upstream_project(self):
90@@ -512,8 +526,25 @@
91 view = create_initialized_view(
92 bug_target, '+bugs', principal=observer)
93 self.assertEqual(None, view.upstream_launchpad_project)
94+ self.assertEqual(None, view.upstream_project)
95 self.assertEqual(None, find_tag_by_id(view(), 'also-in-upstream'))
96
97+ def test_filter_by_upstream_target(self):
98+ # If an upstream target is specified is the query parameters,
99+ # the corresponding flag in BugTaskSearchParams is set.
100+ upstream_project = self._makeBugTargetProduct(
101+ bug_tracker='launchpad', packaging=True)
102+ bug_target = self._getBugTarget(
103+ upstream_project.distrosourcepackages[0])
104+ form = {
105+ 'search': 'Search',
106+ 'advanced': 1,
107+ 'field.upstream_target': upstream_project.name,
108+ }
109+ view = create_initialized_view(bug_target, '+bugs', form=form)
110+ search_params = view.buildSearchParams()
111+ self.assertEqual(upstream_project, search_params.upstream_target)
112+
113
114 class TestBugTaskSearchListingViewSP(TestBugTaskSearchListingViewDSP):
115
116
117=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
118--- lib/lp/bugs/interfaces/bugtask.py 2012-02-01 17:18:46 +0000
119+++ lib/lp/bugs/interfaces/bugtask.py 2012-02-07 11:04:19 +0000
120@@ -1066,6 +1066,9 @@
121 vocabulary=BugTagsSearchCombinator, required=False,
122 default=BugTagsSearchCombinator.ANY)
123
124+ upstream_target = Choice(
125+ title=_('Project'), required=False, vocabulary='Product')
126+
127
128 class IPersonBugTaskSearch(IBugTaskSearchBase):
129 """The schema used by the bug task search form of a person."""
130
131=== modified file 'lib/lp/bugs/templates/bugtask-macros-tableview.pt'
132--- lib/lp/bugs/templates/bugtask-macros-tableview.pt 2012-02-01 15:31:32 +0000
133+++ lib/lp/bugs/templates/bugtask-macros-tableview.pt 2012-02-07 11:04:19 +0000
134@@ -546,15 +546,41 @@
135 </table>
136 </fieldset>
137
138- <fieldset tal:condition="view/shouldShowUpstreamStatusBox">
139- <legend>Upstream status</legend>
140- <table>
141- <tr>
142- <td style="white-space: nowrap"
143- tal:content="structure view/widgets/status_upstream" />
144- </tr>
145- </table>
146- </fieldset>
147+ <tal:show_upstream_widgets condition="view/shouldShowUpstreamStatusBox">
148+ <fieldset>
149+ <legend>Upstream status</legend>
150+ <table>
151+ <tr>
152+ <td style="white-space: nowrap"
153+ tal:content="structure view/widgets/status_upstream" />
154+ </tr>
155+ </table>
156+ </fieldset>
157+
158+ <fieldset tal:condition="view/upstream_project">
159+ <legend>Upstream target</legend>
160+ <table>
161+ <tr>
162+ <td style="white-space: nowrap">
163+ <label>
164+ <input id="field.upstream_target"
165+ name="field.upstream_target"
166+ value="" checked="checked" class="radioType"
167+ type="radio" />
168+ All possible upstream targets
169+ </label><br />
170+ <label>
171+ <input id="field.upstream_target"
172+ name="field.upstream_target"
173+ class="radioType" type="radio"
174+ tal:attributes="value view/upstream_project/name" />
175+ <span tal:replace="view/upstream_project/displayname" />
176+ </label>
177+ </td>
178+ </tr>
179+ </table>
180+ </fieldset>
181+ </tal:show_upstream_widgets>
182
183 <fieldset>
184 <legend>Bug relationships</legend>