Merge ~cjwatson/launchpad:built-using-ui into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: d6e1f11cf62ea77938ce3cc4fa6b578d1fac8daf
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:built-using-ui
Merge into: launchpad:master
Prerequisite: ~cjwatson/launchpad:built-using-model
Diff against target: 129 lines (+56/-4)
5 files modified
lib/lp/soyuz/browser/binarypackagerelease.py (+19/-3)
lib/lp/soyuz/browser/configure.zcml (+3/-0)
lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt (+19/-1)
lib/lp/soyuz/templates/binarypackagerelease-portlet-builtusing.pt (+14/-0)
lib/lp/soyuz/templates/distroarchseriesbinarypackagerelease-index.pt (+1/-0)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+381237@code.launchpad.net

Commit message

Show Built-Using references in the web UI

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/soyuz/browser/binarypackagerelease.py b/lib/lp/soyuz/browser/binarypackagerelease.py
2index 74782db..e21110d 100644
3--- a/lib/lp/soyuz/browser/binarypackagerelease.py
4+++ b/lib/lp/soyuz/browser/binarypackagerelease.py
5@@ -1,4 +1,4 @@
6-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
7+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 __metaclass__ = type
11@@ -9,8 +9,14 @@ __all__ = [
12 ]
13
14 from lp.services.webapp import Navigation
15-from lp.services.webapp.publisher import LaunchpadView
16-from lp.soyuz.browser.packagerelationship import relationship_builder
17+from lp.services.webapp.publisher import (
18+ canonical_url,
19+ LaunchpadView,
20+ )
21+from lp.soyuz.browser.packagerelationship import (
22+ PackageRelationshipSet,
23+ relationship_builder,
24+ )
25 from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageRelease
26
27
28@@ -55,3 +61,13 @@ class BinaryPackageView(LaunchpadView):
29
30 def breaks(self):
31 return self._relationship_parser(self.context.breaks)
32+
33+ def built_using(self):
34+ relationship_set = PackageRelationshipSet()
35+ for reference in self.context.built_using_references:
36+ spr = reference.source_package_release
37+ sp = spr.upload_distroseries.getSourcePackage(
38+ spr.sourcepackagename)
39+ sp_url = canonical_url(sp) if sp is not None else None
40+ relationship_set.add(spr.name, '=', spr.version, sp_url)
41+ return relationship_set
42diff --git a/lib/lp/soyuz/browser/configure.zcml b/lib/lp/soyuz/browser/configure.zcml
43index 4ab2e41..5aea5bd 100644
44--- a/lib/lp/soyuz/browser/configure.zcml
45+++ b/lib/lp/soyuz/browser/configure.zcml
46@@ -72,6 +72,9 @@
47 <browser:page
48 name="+portlet-breaks"
49 template="../templates/binarypackagerelease-portlet-breaks.pt"/>
50+ <browser:page
51+ name="+portlet-builtusing"
52+ template="../templates/binarypackagerelease-portlet-builtusing.pt"/>
53 </browser:pages>
54 <browser:pages
55 for="lp.soyuz.interfaces.sourcepackagerelease.ISourcePackageRelease"
56diff --git a/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt b/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt
57index 0919a00..09d9edf 100644
58--- a/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt
59+++ b/lib/lp/soyuz/stories/soyuz/xx-binarypackagerelease-index.txt
60@@ -29,6 +29,18 @@ XXX: noodles 2009-01-16 bug 317863: move this into the STP.
61
62 >>> login('foo.bar@canonical.com')
63 >>> build = getUtility(IBinaryPackageBuildSet).getByID(2)
64+
65+The sample data doesn't have any Built-Using references. For now, just
66+manually insert one so that we can check how it's rendered.
67+
68+ >>> from lp.soyuz.enums import BinarySourceReferenceType
69+ >>> from lp.soyuz.interfaces.binarysourcereference import (
70+ ... IBinarySourceReferenceSet,
71+ ... )
72+ >>> bpr = build.getBinaryPackageRelease('mozilla-firefox')
73+ >>> _ = getUtility(IBinarySourceReferenceSet).createFromRelationship(
74+ ... bpr, 'iceweasel (= 1.0)', BinarySourceReferenceType.BUILT_USING)
75+
76 >>> package_upload = build.distro_series.createQueueEntry(
77 ... PackagePublishingPocket.UPDATES, build.archive,
78 ... 'changes.txt', b'my changes')
79@@ -73,11 +85,17 @@ links to a binary in the context in question.
80 TEXT: "bar"
81 LINK: "pmount" -> http://launchpad.test/ubuntu/warty/i386/pmount
82
83-
84 >>> print_relation('breaks')
85 TEXT: "baz"
86 LINK: "pmount" -> http://launchpad.test/ubuntu/warty/i386/pmount
87
88+The 'Built-Using' section contains a link to a source in the context in
89+question.
90+
91+ >>> print_relation('builtusing')
92+ LINK: "iceweasel (= 1.0)" ->
93+ http://launchpad.test/ubuntu/warty/+source/iceweasel
94+
95
96 'Depends', 'Conflicts', 'Replaces', 'Suggests' and 'Recommends'
97 sections contain only unsatisfied dependencies, which are rendered as
98diff --git a/lib/lp/soyuz/templates/binarypackagerelease-portlet-builtusing.pt b/lib/lp/soyuz/templates/binarypackagerelease-portlet-builtusing.pt
99new file mode 100644
100index 0000000..08645f4
101--- /dev/null
102+++ b/lib/lp/soyuz/templates/binarypackagerelease-portlet-builtusing.pt
103@@ -0,0 +1,14 @@
104+<div
105+ xmlns:tal="http://xml.zope.org/namespaces/tal"
106+ xmlns:metal="http://xml.zope.org/namespaces/metal"
107+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
108+ tal:define="relationships view/built_using"
109+ tal:condition="relationships/has_items"
110+ class="first yui-u" id="portlet-builtusing">
111+
112+ <dl id="builtusing">
113+ <dt>Built-Using:</dt>
114+ <tal:block replace="structure relationships/@@+render-list"/>
115+ </dl>
116+
117+</div>
118diff --git a/lib/lp/soyuz/templates/distroarchseriesbinarypackagerelease-index.pt b/lib/lp/soyuz/templates/distroarchseriesbinarypackagerelease-index.pt
119index d5a97b1..a9586c1 100644
120--- a/lib/lp/soyuz/templates/distroarchseriesbinarypackagerelease-index.pt
121+++ b/lib/lp/soyuz/templates/distroarchseriesbinarypackagerelease-index.pt
122@@ -87,6 +87,7 @@
123 <div tal:replace="structure bpr/@@+portlet-predepends" />
124 <div tal:replace="structure bpr/@@+portlet-enhances" />
125 <div tal:replace="structure bpr/@@+portlet-breaks" />
126+ <div tal:replace="structure bpr/@@+portlet-builtusing" />
127
128 </div><!--portlet-->
129 </div><!--yui-g-->

Subscribers

People subscribed via source and target branches

to status/vote changes: