Merge lp:~edwin-grubbs/launchpad/bug-667900-dsp-page-upstream-link-form into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: 11950
Proposed branch: lp:~edwin-grubbs/launchpad/bug-667900-dsp-page-upstream-link-form
Merge into: lp:launchpad
Diff against target: 234 lines (+76/-29)
5 files modified
lib/lp/registry/browser/distributionsourcepackage.py (+23/-4)
lib/lp/registry/browser/tests/distributionsourcepackage-views.txt (+35/-1)
lib/lp/registry/templates/distributionsourcepackage-index.pt (+9/-20)
lib/lp/registry/templates/sourcepackage-upstream-connections.pt (+1/-0)
lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt (+8/-4)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-667900-dsp-page-upstream-link-form
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code + ui Approve
j.c.sackett (community) code* Approve
Review via email: mp+41025@code.launchpad.net

Commit message

[r=jcsackett,sinzui][ui=sinzui][bug=667900] Add form to DistributionSourcePackage +index page to set upstream project link more easily.

Description of the change

Summary
-------

Display form on DistributionSourcePackage page if the latest
sourcepackage does not have a link to an upstream project.

An upstream link isn't really needed for sourcepackages that are not
current or in development, so don't display the "Set upstream link" for
those older sourcepackages on this page.

Tests
-----

./bin/test -vv -t distributionsourcepackage-views.txt

Demo and Q/A
------------

* Open http://launchpad.dev/ubuntu/+source/alsa-utils
    * If you remove the upstream link from the latest sourcepackage, a
      form should be displayed.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :
Download full text (8.4 KiB)

> Edwin--
>
> This is a really nicely done branch below. I have some comments, but they're mostly for my own edification, not issues with the code.
>
> === modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
> --- lib/lp/registry/browser/distributionsourcepackage.py 2010-11-06 06:52:31 +0000
> +++ lib/lp/registry/browser/distributionsourcepackage.py 2010-11-17 00:32:27 +0000
> @@ -31,7 +31,6 @@
> Interface,
> )
>
> -from canonical.launchpad.webapp.interfaces import IBreadcrumb
> from canonical.launchpad.helpers import shortlist
> from canonical.launchpad.webapp import (
> action,
> @@ -43,6 +42,7 @@
> StandardLaunchpadFacets,
> )
> from canonical.launchpad.webapp.breadcrumb import Breadcrumb
> +from canonical.launchpad.webapp.interfaces import IBreadcrumb
> from canonical.launchpad.webapp.menu import (
> ApplicationMenu,
> enabled_with_permission,
> @@ -50,14 +50,14 @@
> NavigationMenu,
> )
> from canonical.launchpad.webapp.sorting import sorted_dotted_numbers
> -from lp.app.interfaces.launchpad import IServiceUsage
> -from lp.app.browser.tales import CustomizableFormatter
> from canonical.lazr.utils import smartquote
> from lp.answers.browser.questiontarget import (
> QuestionTargetFacetMixin,
> QuestionTargetTraversalMixin,
> )
> from lp.answers.interfaces.questionenums import QuestionStatus
> +from lp.app.browser.tales import CustomizableFormatter
> +from lp.app.interfaces.launchpad import IServiceUsage
> from lp.bugs.browser.bugtask import BugTargetTraversalMixin
> from lp.bugs.interfaces.bug import IBugSet
> from lp.registry.browser.pillar import PillarBugsMenu
> @@ -68,6 +68,7 @@
> IDistributionSourcePackage,
> )
> from lp.registry.interfaces.pocket import pocketsuffix
> +from lp.registry.interfaces.series import SeriesStatus
> from lp.services.propertycache import cachedproperty
> from lp.soyuz.browser.sourcepackagerelease import (
> extract_bug_numbers,

Thanks for cleaning up those imports.

> @@ -409,7 +410,7 @@
> packages_dict[package.distroseries] = package
> return packages_dict
>
> - @property
> + @cachedproperty
> def active_series(self):
> """Return active distroseries where this package is published.
>
> I have to confess to a lack of understanding on cachedproperty--I assume this doesn't change often enough for caching to present a problem? I can see where not caching could produce performance issues, particularly with the increased calls to this method in your other changes. This isn't a problem with the code, just me asking for my own edification.
>
>
> @@ -438,6 +439,13 @@
> return pocket_dict
>
> @property
> + def latest_sourcepackage(self):
> + if len(self.active_series) == 0:
> + return None
> + return self.active_series[0].getSourcePackage(
> + self.context.sourcepackagename)
> +
> + @property
> def version_table(self):
> """Rows of data for the template to render in the packaging table."""
> rows = []
> @@ -446,6 +454,16 @@
> # The first row for each series is the "title" row.
> packaging = packages_by_series[distroseries]....

Read more...

review: Approve (code*)
Revision history for this message
Curtis Hovey (sinzui) wrote :

One of the opportunities we have at the moment is giving users a consistent experience. We will have to reopen a bug if we drop the logo and summary. Why are they missing from the SP page? We should be showing the icon and summary in the portlet. We may not need the logo since we show the icon.

What to do think Edwin? logo or icon?

review: Needs Information (code + ui)
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you for adding the project summary to the portlet. I like the consistency we have on these pages.

review: Approve (code + ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
2--- lib/lp/registry/browser/distributionsourcepackage.py 2010-11-06 06:52:31 +0000
3+++ lib/lp/registry/browser/distributionsourcepackage.py 2010-11-19 15:06:35 +0000
4@@ -31,7 +31,6 @@
5 Interface,
6 )
7
8-from canonical.launchpad.webapp.interfaces import IBreadcrumb
9 from canonical.launchpad.helpers import shortlist
10 from canonical.launchpad.webapp import (
11 action,
12@@ -43,6 +42,7 @@
13 StandardLaunchpadFacets,
14 )
15 from canonical.launchpad.webapp.breadcrumb import Breadcrumb
16+from canonical.launchpad.webapp.interfaces import IBreadcrumb
17 from canonical.launchpad.webapp.menu import (
18 ApplicationMenu,
19 enabled_with_permission,
20@@ -50,14 +50,14 @@
21 NavigationMenu,
22 )
23 from canonical.launchpad.webapp.sorting import sorted_dotted_numbers
24-from lp.app.interfaces.launchpad import IServiceUsage
25-from lp.app.browser.tales import CustomizableFormatter
26 from canonical.lazr.utils import smartquote
27 from lp.answers.browser.questiontarget import (
28 QuestionTargetFacetMixin,
29 QuestionTargetTraversalMixin,
30 )
31 from lp.answers.interfaces.questionenums import QuestionStatus
32+from lp.app.browser.tales import CustomizableFormatter
33+from lp.app.interfaces.launchpad import IServiceUsage
34 from lp.bugs.browser.bugtask import BugTargetTraversalMixin
35 from lp.bugs.interfaces.bug import IBugSet
36 from lp.registry.browser.pillar import PillarBugsMenu
37@@ -68,6 +68,7 @@
38 IDistributionSourcePackage,
39 )
40 from lp.registry.interfaces.pocket import pocketsuffix
41+from lp.registry.interfaces.series import SeriesStatus
42 from lp.services.propertycache import cachedproperty
43 from lp.soyuz.browser.sourcepackagerelease import (
44 extract_bug_numbers,
45@@ -409,7 +410,7 @@
46 packages_dict[package.distroseries] = package
47 return packages_dict
48
49- @property
50+ @cachedproperty
51 def active_series(self):
52 """Return active distroseries where this package is published.
53
54@@ -438,6 +439,13 @@
55 return pocket_dict
56
57 @property
58+ def latest_sourcepackage(self):
59+ if len(self.active_series) == 0:
60+ return None
61+ return self.active_series[0].getSourcePackage(
62+ self.context.sourcepackagename)
63+
64+ @property
65 def version_table(self):
66 """Rows of data for the template to render in the packaging table."""
67 rows = []
68@@ -446,6 +454,16 @@
69 # The first row for each series is the "title" row.
70 packaging = packages_by_series[distroseries].direct_packaging
71 package = packages_by_series[distroseries]
72+ # Don't show the "Set upstream link" action for older series
73+ # without packaging info, so the user won't feel required to
74+ # fill it in.
75+ show_set_upstream_link = (
76+ packaging is None
77+ and distroseries.status in (
78+ SeriesStatus.CURRENT,
79+ SeriesStatus.DEVELOPMENT,
80+ )
81+ )
82 title_row = {
83 'blank_row': False,
84 'title_row': True,
85@@ -453,6 +471,7 @@
86 'distroseries': distroseries,
87 'series_package': package,
88 'packaging': packaging,
89+ 'show_set_upstream_link': show_set_upstream_link,
90 }
91 rows.append(title_row)
92
93
94=== modified file 'lib/lp/registry/browser/tests/distributionsourcepackage-views.txt'
95--- lib/lp/registry/browser/tests/distributionsourcepackage-views.txt 2010-08-24 15:29:01 +0000
96+++ lib/lp/registry/browser/tests/distributionsourcepackage-views.txt 2010-11-19 15:06:35 +0000
97@@ -59,13 +59,47 @@
98 ... distroseries=latest_series)
99 >>> transaction.commit()
100 >>> ubuntu_eel = ubuntutest.getSourcePackage('eel')
101- >>> view = create_initialized_view(ubuntu_eel, name='+index')
102+ >>> view = create_initialized_view(
103+ ... ubuntu_eel, name='+index', principal=factory.makePerson())
104 >>> for series in view.active_series:
105 ... print series.name, series.version
106 latest 10.04
107 breezy-autotest 6.6.6
108 earliest 1.1
109
110+The view has a latest_sourcepackage attribute whose series is the same
111+as the first series from view.active_series.
112+
113+ >>> latest_series = view.latest_sourcepackage.distroseries
114+ >>> print latest_series.name, latest_series.version
115+ latest 10.04
116+
117+The view has a version_table attribute for populating a table. The "Set
118+upstream link" action should only be displayed for series with the status
119+CURRENT or DEVELOPMENT.
120+
121+ >>> view.active_series[1].status = SeriesStatus.CURRENT
122+ >>> view.active_series[2].status = SeriesStatus.SUPPORTED
123+ >>> for row in view.version_table:
124+ ... if row.get('distroseries') is not None:
125+ ... set_upstream_link = ''
126+ ... if row['show_set_upstream_link'] is True:
127+ ... set_upstream_link = ' set-upstream-link'
128+ ... ds = row['distroseries']
129+ ... print "%-16s %-12s %s" % (
130+ ... ds.name, ds.status.name, set_upstream_link)
131+ latest DEVELOPMENT set-upstream-link
132+ breezy-autotest CURRENT set-upstream-link
133+ earliest SUPPORTED
134+
135+If the latest sourcepackage does not have a link to an upstream project,
136+this page will display a form to add one.
137+
138+ >>> from canonical.launchpad.testing.pages import find_tag_by_id
139+ >>> upstream_portlet = find_tag_by_id(view.render(), 'upstream')
140+ >>> print upstream_portlet.find(id='field.actions.link')['value']
141+ Link to Upstream Project
142+
143
144 Related PPA versions
145 --------------------
146
147=== modified file 'lib/lp/registry/templates/distributionsourcepackage-index.pt'
148--- lib/lp/registry/templates/distributionsourcepackage-index.pt 2010-07-02 15:10:10 +0000
149+++ lib/lp/registry/templates/distributionsourcepackage-index.pt 2010-11-19 15:06:35 +0000
150@@ -93,25 +93,14 @@
151
152 <div class="yui-u">
153 <div class="portlet" id="upstream">
154- <tal:project define="project context/upstream_product">
155- <div tal:condition="project">
156- <h2>Upstream</h2>
157- <div style="float:left; padding:0 1em 1em 0;">
158- <a
159- tal:attributes="href project/fmt:url"
160- tal:content="structure project/image:logo" />
161- </div>
162- <div>
163- <a
164- tal:attributes="href project/fmt:url"
165- tal:content="project/displayname" />
166- </div>
167- <div tal:content="structure project/summary" />
168- </div>
169- <tal:noproject condition="not: project">
170- This package is not linked to an upstream product.
171- </tal:noproject>
172- </tal:project>
173+ <div tal:condition="not: view/active_series">
174+ <h2>Upstream</h2>
175+ This package is no longer tracking upstream.
176+ </div>
177+ <tal:published_series
178+ condition="view/active_series"
179+ replace="structure view/latest_sourcepackage/@@+portlet-associations"
180+ />
181 </div><!--portlet -->
182 </div><!--yui-u -->
183
184@@ -132,7 +121,7 @@
185 tal:content="row/distroseries/title"/>
186 (<span tal:replace="row/distroseries/status/title/lower"/>)
187 <div style="float:right; white-space: nowrap">
188- <a tal:condition="not: row/packaging"
189+ <a tal:condition="row/show_set_upstream_link"
190 tal:replace="structure row/series_package/menu:overview/set_upstream/fmt:link"/>
191 <tal:has_packaging condition="row/packaging">
192 <img tal:replace="structure row/packaging/productseries/image:icon"/>
193
194=== modified file 'lib/lp/registry/templates/sourcepackage-upstream-connections.pt'
195--- lib/lp/registry/templates/sourcepackage-upstream-connections.pt 2010-11-10 19:16:33 +0000
196+++ lib/lp/registry/templates/sourcepackage-upstream-connections.pt 2010-11-19 15:06:35 +0000
197@@ -25,6 +25,7 @@
198 </span>
199 </dd>
200 </dl>
201+ <p tal:content="series/product/summary"/>
202
203 <style>
204 #upstream-fields dd {
205
206=== modified file 'lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt'
207--- lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt 2010-08-24 15:29:01 +0000
208+++ lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt 2010-11-19 15:06:35 +0000
209@@ -291,7 +291,9 @@
210 is used in another section:
211
212 >>> print extract_text(find_tag_by_id(user_browser.contents, 'upstream'))
213- This package is not linked to an upstream product.
214+ Upstream connections
215+ Launchpad doesn...t know which project and series this
216+ package belongs to...
217
218 As can be seen, the packaging is not linked yet. We can do that now using the
219 "Set upstream link" link.
220@@ -319,9 +321,11 @@
221
222 >>> user_browser.open("http://launchpad.dev/ubuntu/+source/iceweasel/")
223 >>> print extract_text(find_tag_by_id(user_browser.contents, 'upstream'))
224- Upstream
225- Mozilla Firefox
226- The Mozilla Firefox web browser
227+ Upstream connections
228+ the Mozilla Project...
229+ Mozilla Firefox...
230+ trunk...
231+ The Mozilla Firefox web browser...
232
233 >>> user_browser.getLink('Mozilla Firefox')
234 <Link text='Mozilla Firefox' url='http://launchpad.dev/firefox'>