Merge lp:~sinzui/launchpad/unlinkable-packages-0 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Eleanor Berger
Approved revision: no longer in the source branch.
Merged at revision: 10883
Proposed branch: lp:~sinzui/launchpad/unlinkable-packages-0
Merge into: lp:launchpad
Diff against target: 293 lines (+84/-28)
6 files modified
lib/lp/registry/browser/sourcepackage.py (+14/-1)
lib/lp/registry/browser/tests/sourcepackage-views.txt (+35/-6)
lib/lp/registry/model/distroseries.py (+4/-1)
lib/lp/registry/stories/packaging/xx-sourcepackage-packaging.txt (+6/-2)
lib/lp/registry/templates/sourcepackage-portlet-associations.pt (+7/-13)
lib/lp/registry/tests/test_distroseries.py (+18/-5)
To merge this branch: bzr merge lp:~sinzui/launchpad/unlinkable-packages-0
Reviewer Review Type Date Requested Status
Eleanor Berger (community) code Approve
Review via email: mp+25260@code.launchpad.net

Description of the change

This is my branch to improve the quality of package listings and linking.

    lp:~sinzui/launchpad/unlinkable-packages-0
    Diff size: 269
    Launchpad bug: https://bugs.launchpad.net/bugs/577492
                   https://bugs.launchpad.net/bugs/577497
                   https://bugs.launchpad.net/bugs/580124
    Test command: ./bin/test -vv \
        -t lp/.*/sourcepackage-views -t xx-sourcepackages-packagings
        -t TestDistroSeriesSet -t TestDistroSeriesPackaging
    Pre-implementation: no one. I started fixing issues as I was triaging.
    Target release: 10.05

Improve the quality of package listings and linking
---------------------------------------------------

Bug 577492 [+needs-packaging lists duplicates]
    I viewed the first 200 items listed in
    https://launchpad.net/ubuntu/maverick/+needs-packaging and +packaging and
    I saw several duplicates. The duplication is not obvious since Ubuntu has
    so many packages.

Bug 577497 [+needs-packaging lists packages that cannot be linked]
    Many metapackages and language packs cannot be linked to upstream
    projects.

Bug 580124 [sourcepackage upstream connections portlet is inconsistent]
    The Upstream connection portlet look different that the project Ubuntu
    packaging portlet. The form is ambiguous because there is a link and and
    button to link to an upstream project. The project version of the form
    solved this by moving the option to choose a different package into the
    form options. Also, the SP form will shown too many matches, which breaks
    the layout. The form will also steal focus, and with a lot of matches, the
    page will scroll.

Rules
-----

Bug 577492 [+needs-packaging lists duplicates]
    * +needs-packaging duplicate is actually random ordering for packages
      with the same score. Add a second sort on spn.name to ensure reloading
      a listing does not get a different listing.
    * This is Ubuntu fix. Another branch is needed to fix the Debian problem
      where many packages can be in the published state.

Bug 577497 [+needs-packaging lists packages that cannot be linked]
    * Lp does not store information regarding metapackage. Some meta packages
      can have code (because of rules). The most visible problem is language
      packs and they are all in the 'translations' section. Exclude that
      section

Bug 580124 [sourcepackage upstream connections portlet is inconsistent]
    * Steal from the product Ubuntu packaging form:
      * Limit the number of items to 10
      * Include an option to choose an alternate upstream project
      * Remove the link that looks redundant
      * Set initial_focus_widget to None

UI
--

    * http://people.canonical.com/~curtis/sp-before.png
      A long list with similarly named button and link
    * http://people.canonical.com/~curtis/sp-after.png
      A shorter list (okay, sample data sucks, the tests show that the list
      cannot be more than 10). A single button to set the upstream project
      and the user can choose an option to chose another unlisted project.

QA
--

Bug 577492 [+needs-packaging lists duplicates]
    * Visit https://edge.launchpad.net/ubuntu/maverick/+needs-packaging?start=100
    * Reload and verify the listing is the same.

Bug 577497 [+needs-packaging lists packages that cannot be linked]
    * Visit https://edge.launchpad.net/ubuntu/maverick/+needs-packaging
      and page though 4 pages.
    * Verify that Language packs are not included.

Bug 580124 [sourcepackage upstream connections portlet is inconsistent]
    * Visit https://edge.launchpad.net/ubuntu/maverick/+source/mpc
    * Verify the page does not scroll down to the show the form.
    * Verify 10 items are listed
    * Verify the last item is "Chose another upstream project"
    * Submit the last items
    * Verify you are seeing the page to enter an upstream project.

Lint
----

Linting changed files:
  lib/lp/registry/browser/sourcepackage.py
  lib/lp/registry/browser/tests/sourcepackage-views.txt
  lib/lp/registry/model/distroseries.py
  lib/lp/registry/templates/sourcepackage-portlet-associations.pt
  lib/lp/registry/tests/test_distroseries.py

Test
----

    * lib/lp/registry/browser/tests/sourcepackage-views.txt
      Updated the test to verify that the matches are limited to 9
      and that an option to choose another project is appended.

    * lib/lp/registry/tests/test_distroseries.py
      Added a test to verify that packages in the translations section are
      excluded. Updated a test to show that items of equal score are sorted
      by name.

Implementation
--------------

    * lib/lp/registry/browser/sourcepackage.py
      Updated the upstream packages form to limit the matches to
      9 and append an option to choose another project. Set the
      initial_focus_widget to None.

    * lib/lp/registry/model/distroseries.py
      Added sourcepakagename.name to the sort rule and added a constraint
      to exclude translations section (language packs.)

    * lib/lp/registry/templates/sourcepackage-portlet-associations.pt
      Moved the paragraph about no matches into the form (just like) the
      project version of this portlet. I removed the ambiguous link.

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/registry/browser/sourcepackage.py'
2--- lib/lp/registry/browser/sourcepackage.py 2010-03-08 10:43:34 +0000
3+++ lib/lp/registry/browser/sourcepackage.py 2010-05-18 17:08:30 +0000
4@@ -439,6 +439,9 @@
5 custom_widget(
6 'upstream', LaunchpadRadioWidget, orientation='vertical')
7 product_suggestions = None
8+ initial_focus_widget = None
9+ max_suggestions = 9
10+ other_upstream = object()
11
12 def setUpFields(self):
13 """See `LaunchpadFormView`."""
14@@ -452,13 +455,18 @@
15 # term descriptions that include a link to the product.
16 self.product_suggestions = []
17 vocab_terms = []
18- for item in matches:
19+ for item in matches[:self.max_suggestions]:
20 product = item.value
21 self.product_suggestions.append(product)
22 item_url = canonical_url(product)
23 description = """<a href="%s">%s</a>""" % (
24 item_url, escape(product.displayname))
25 vocab_terms.append(SimpleTerm(product, product.name, description))
26+ # Add an option to represent the user's decision to choose a
27+ # different project. Note that project names cannot be uppercase.
28+ description = 'Choose another upstream project'
29+ vocab_terms.append(
30+ SimpleTerm(self.other_upstream, 'OTHER_UPSTREAM', description))
31 upstream_vocabulary = SimpleVocabulary(vocab_terms)
32
33 self.form_fields = Fields(
34@@ -471,6 +479,11 @@
35 @action('Link to Upstream Project', name='link')
36 def link(self, action, data):
37 upstream = data.get('upstream')
38+ if upstream is self.other_upstream:
39+ # The user wants to link to an alternate upstream project.
40+ self.next_url = canonical_url(
41+ self.context, view_name="+edit-packaging")
42+ return
43 self.context.setPackaging(upstream.development_focus, self.user)
44 self.request.response.addInfoNotification(
45 'The project %s was linked to this source package.' %
46
47=== modified file 'lib/lp/registry/browser/tests/sourcepackage-views.txt'
48--- lib/lp/registry/browser/tests/sourcepackage-views.txt 2010-03-03 00:40:03 +0000
49+++ lib/lp/registry/browser/tests/sourcepackage-views.txt 2010-05-18 17:08:30 +0000
50@@ -197,17 +197,29 @@
51 package belongs to. ...
52 Is the following project the upstream for this source package?
53 Registered upstream project:
54- Lernid...
55-
56-If there are multiple potential matches they are all shown.
57-
58- >>> product = factory.makeProduct(name='lernid-dev', displayname='Lernid Dev')
59+ Lernid
60+ Choose another upstream project
61+
62+The form does not steal focus because it is not the primary purpose of the
63+page.
64+
65+ >>> print view.initial_focus_widget
66+ None
67+
68+If there are multiple potential matches, the first 9 are shown. The 10th
69+item is reserved for the "Choose another upstream project" option.
70+
71+ >>> product = factory.makeProduct(
72+ ... name='lernid-dev', displayname='Lernid Dev')
73 >>> view = create_initialized_view(package, name='+portlet-associations')
74 >>> for product in view.product_suggestions:
75 ... print product.name
76 lernid
77 lernid-dev
78
79+ >>> view.max_suggestions
80+ 9
81+
82 >>> content = extract_text(find_tag_by_id(view.render(), 'no-upstreams'))
83 >>> print content
84 Launchpad doesn&#8217;t know which project and series this
85@@ -216,6 +228,21 @@
86 Registered upstream project:
87 Lernid...
88 Lernid Dev...
89+ Choose another upstream project
90+
91+Choosing the "Choose another upstream project" option redirects the user
92+to the +edit-packaging page where the user can search for a project.
93+
94+ >>> form = {
95+ ... 'field.upstream': 'OTHER_UPSTREAM',
96+ ... 'field.actions.link': 'Link to Upstream Project',
97+ ... }
98+ >>> view = create_initialized_view(
99+ ... package, name='+portlet-associations', form=form)
100+ >>> view.errors
101+ []
102+ >>> print view.next_url
103+ http://launchpad.dev/youbuntu/busy/+source/lernid/+edit-packaging
104
105
106 Upstream connections view
107@@ -328,6 +355,8 @@
108
109 >>> view = create_initialized_view(package, name='+portlet-associations')
110 >>> print extract_text(find_tag_by_id(view.render(), 'no-upstreams'))
111+ Launchpad doesn&#8217;t know which project ...
112 There are no projects registered in Launchpad that are a potential
113 match for this source package. Can you help us find one?
114- Set upstream link
115+ Registered upstream project:
116+ Choose another upstream project
117
118=== modified file 'lib/lp/registry/model/distroseries.py'
119--- lib/lp/registry/model/distroseries.py 2010-04-22 08:47:32 +0000
120+++ lib/lp/registry/model/distroseries.py 2010-05-18 17:08:30 +0000
121@@ -371,7 +371,7 @@
122 """)
123 condition = SQL(conditions + "AND packaging.id IS NOT NULL")
124 results = IStore(self).using(origin).find(find_spec, condition)
125- results = results.order_by('score DESC')
126+ results = results.order_by('score DESC, SourcePackageName.name ASC')
127 return [packaging
128 for (packaging, spn, series, product, score) in results]
129
130@@ -433,6 +433,8 @@
131 ON spr.id = spph.sourcepackagerelease
132 JOIN archive
133 ON spph.archive = Archive.id
134+ JOIN section
135+ ON spph.section = section.id
136 JOIN DistroSeries
137 ON spph.distroseries = DistroSeries.id
138 LEFT JOIN Packaging
139@@ -443,6 +445,7 @@
140 DistroSeries.id = %(distroseries)s
141 AND spph.status IN %(active_status)s
142 AND archive.purpose = %(primary)s
143+ AND section.name != 'translations'
144 """ % sqlvalues(
145 distroseries=self,
146 active_status=active_publishing_status,
147
148=== modified file 'lib/lp/registry/stories/packaging/xx-sourcepackage-packaging.txt'
149--- lib/lp/registry/stories/packaging/xx-sourcepackage-packaging.txt 2010-03-08 01:51:58 +0000
150+++ lib/lp/registry/stories/packaging/xx-sourcepackage-packaging.txt 2010-05-18 17:08:30 +0000
151@@ -15,14 +15,18 @@
152 >>> user_browser.getLink('pmount').click()
153 >>> print extract_text(find_tag_by_id(
154 ... user_browser.contents, 'no-upstreams'))
155+ Launchpad...
156 There are no projects registered in Launchpad that are a potential
157 match for this source package. Can you help us find one?
158- Set upstream link
159+ Registered upstream project:
160+ Choose another upstream project
161
162 No Privileges Person knows that the pmount package comes from the thunderbird
163 project. He sets the upstream packaging link and sees that it is set.
164
165- >>> user_browser.getLink('Set upstream link').click()
166+ >>> user_browser.getControl(
167+ ... 'Choose another upstream project').selected = True
168+ >>> user_browser.getControl("Link to Upstream Project").click()
169 >>> user_browser.getControl(name='field.product').value = 'thunderbird'
170 >>> user_browser.getControl('Continue').click()
171 >>> user_browser.getControl(name='field.productseries').value = ['trunk']
172
173=== modified file 'lib/lp/registry/templates/sourcepackage-portlet-associations.pt'
174--- lib/lp/registry/templates/sourcepackage-portlet-associations.pt 2010-02-26 22:59:30 +0000
175+++ lib/lp/registry/templates/sourcepackage-portlet-associations.pt 2010-05-18 17:08:30 +0000
176@@ -22,7 +22,7 @@
177 </tal:has_series>
178
179 <tal:has_no_series condition="not: series">
180- <div id="no-upstreams" tal:condition="view/product_suggestions">
181+ <div id="no-upstreams">
182 <p>
183 Launchpad doesn&#8217;t know which project and series this
184 package belongs to. Links from distribution packages to
185@@ -31,11 +31,16 @@
186 efficiently.
187 </p>
188
189+ <p tal:condition="not: view/product_suggestions">
190+ There are no projects registered in Launchpad that are a potential
191+ match for this source package. Can you help us find one?
192+ </p>
193+
194 <tal:message
195 define="count python:len(view.product_suggestions);
196 singular string:Is the following project the upstream for this source package?;
197 plural string:Is one of these projects the upstream for this source package?"
198- >
199+ condition="view/product_suggestions">
200 <b>
201 <metal:message use-macro="context/@@+base-layout-macros/plural-message"/>
202 </b>
203@@ -44,20 +49,9 @@
204 <div metal:use-macro="context/@@launchpad_form/form">
205 <div class="actions" metal:fill-slot="buttons">
206 <input tal:replace="structure view/link/render"/>
207- &nbsp;or&nbsp;
208- <a tal:replace="structure
209- context/menu:overview/set_upstream/fmt:link" />
210 </div>
211 </div>
212 </div>
213- <div id="no-upstreams" tal:condition="not: view/product_suggestions">
214- <p>
215- There are no projects registered in Launchpad that are a potential
216- match for this source package. Can you help us find one?
217- </p>
218- <a tal:replace="structure
219- context/menu:overview/set_upstream/fmt:link" />
220- </div>
221 </tal:has_no_series>
222 </div>
223 </div>
224
225=== modified file 'lib/lp/registry/tests/test_distroseries.py'
226--- lib/lp/registry/tests/test_distroseries.py 2010-03-23 00:39:45 +0000
227+++ lib/lp/registry/tests/test_distroseries.py 2010-05-18 17:08:30 +0000
228@@ -219,16 +219,21 @@
229 login(ANONYMOUS)
230
231 def makeSeriesPackage(self, name,
232- is_main=False, heat=None, messages=None):
233+ is_main=False, heat=None, messages=None,
234+ is_translations=False):
235 # Make a published source package.
236 if is_main:
237 component = self.main_component
238 else:
239 component = self.universe_component
240+ if is_translations:
241+ section = 'translations'
242+ else:
243+ section = 'web'
244 sourcepackagename = self.factory.makeSourcePackageName(name)
245 self.factory.makeSourcePackagePublishingHistory(
246 sourcepackagename=sourcepackagename, distroseries=self.series,
247- component=component)
248+ component=component, section=section)
249 source_package = self.factory.makeSourcePackage(
250 sourcepackagename=sourcepackagename, distroseries=self.series)
251 if heat is not None:
252@@ -256,6 +261,15 @@
253 u'main', u'hot-translatable', u'hot', u'translatable', u'normal']
254 self.assertEqual(expected, names)
255
256+ def test_getPrioritizedUnlinkedSourcePackages_no_language_packs(self):
257+ # Verify that translations packages are not listed.
258+ self.makeSeriesPackage('language-pack-vi', is_translations=True)
259+ package_summaries = self.series.getPrioritizedUnlinkedSourcePackages()
260+ names = [summary['package'].name for summary in package_summaries]
261+ expected = [
262+ u'main', u'hot-translatable', u'hot', u'translatable', u'normal']
263+ self.assertEqual(expected, names)
264+
265 def test_getPrioritizedlPackagings(self):
266 # Verify the ordering of packagings that need more upstream info.
267 for name in ['main', 'hot-translatable', 'hot', 'translatable']:
268@@ -274,7 +288,7 @@
269 product_series.product.bugtraker = self.factory.makeBugTracker()
270 packagings = self.series.getPrioritizedlPackagings()
271 names = [packaging.sourcepackagename.name for packaging in packagings]
272- expected = [u'hot', u'linked', u'cold']
273+ expected = [u'hot', u'cold', u'linked']
274 self.assertEqual(expected, names)
275
276 def test_getPrioritizedlPackagings_branch(self):
277@@ -339,7 +353,7 @@
278 translatables, self._ref_translatables()))
279
280 new_sourcepackagename = self.factory.makeSourcePackageName()
281- new_potemplate = self.factory.makePOTemplate(
282+ self.factory.makePOTemplate(
283 distroseries=new_distroseries,
284 sourcepackagename=new_sourcepackagename)
285 transaction.commit()
286@@ -368,7 +382,6 @@
287
288 def test_fromSuite_non_release_pocket(self):
289 series = self.factory.makeDistroRelease()
290- pocket = PackagePublishingPocket.BACKPORTS
291 suite = '%s-backports' % series.name
292 result = getUtility(IDistroSeriesSet).fromSuite(
293 series.distribution, suite)