Merge lp://staging/~julian-edwards/launchpad/breadcrumbs-bug-423242 into lp://staging/launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~julian-edwards/launchpad/breadcrumbs-bug-423242
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~julian-edwards/launchpad/breadcrumbs-bug-423242
Reviewer Review Type Date Requested Status
Celso Providelo (community) code Approve
Review via email: mp+11069@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

= Summary =
Add breadcrumbs to DistroArchSeries and onwards traversals

== Pre-implementation notes ==
Salgado advised on how to do this, it's trivial to add and test.

== Implementation details ==
I added breadcrumbs for DistroArchSeries[BinaryPackage][Release] pages in 2
stages:
 * Add an adapter to the browser class
 * Register it in the zcml

== Tests ==
New tests added, run:
bin/test -vvt TestDistroArchSeriesBreadcrumb

== Demo and Q/A ==
See
https://launchpad.dev/ubuntu/hoary/i386
https://launchpad.dev/ubuntu/hoary/i386/pmount
https://launchpad.dev/ubuntu/hoary/i386/pmount/0.1-1

= 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/soyuz/browser/tests/test_breadcrumbs.py
  lib/lp/soyuz/configure.zcml
  lib/lp/soyuz/browser/distroarchseriesbinarypackagerelease.py
  lib/lp/soyuz/browser/distroarchseriesbinarypackage.py
  lib/lp/soyuz/browser/distroarchseries.py

Revision history for this message
Celso Providelo (cprov) wrote :

Very good change, Julian.

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/soyuz/browser/distroarchseries.py'
2--- lib/lp/soyuz/browser/distroarchseries.py 2009-08-21 19:45:35 +0000
3+++ lib/lp/soyuz/browser/distroarchseries.py 2009-09-02 16:03:13 +0000
4@@ -7,6 +7,7 @@
5 'DistroArchSeriesActionMenu',
6 'DistroArchSeriesAddView',
7 'DistroArchSeriesAdminView',
8+ 'DistroArchSeriesBreadcrumb',
9 'DistroArchSeriesPackageSearchView',
10 'DistroArchSeriesNavigation',
11 'DistroArchSeriesView',
12@@ -20,6 +21,7 @@
13 from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
14 from canonical.launchpad.webapp import (
15 GetitemNavigation, LaunchpadEditFormView)
16+from canonical.launchpad.webapp.breadcrumb import Breadcrumb
17 from canonical.launchpad.webapp.launchpadform import (
18 action, LaunchpadFormView)
19 from canonical.launchpad.webapp.menu import (
20@@ -33,6 +35,14 @@
21 usedfor = IDistroArchSeries
22
23
24+class DistroArchSeriesBreadcrumb(Breadcrumb):
25+ """Builds a breadcrumb for `DistroArchSeries`."""
26+
27+ @property
28+ def text(self):
29+ return self.context.architecturetag
30+
31+
32 class IDistroArchSeriesActionMenu(Interface):
33 """Marker interface for the action menu."""
34
35
36=== modified file 'lib/lp/soyuz/browser/distroarchseriesbinarypackage.py'
37--- lib/lp/soyuz/browser/distroarchseriesbinarypackage.py 2009-06-25 04:06:00 +0000
38+++ lib/lp/soyuz/browser/distroarchseriesbinarypackage.py 2009-09-02 16:22:02 +0000
39@@ -4,6 +4,7 @@
40 __metaclass__ = type
41
42 __all__ = [
43+ 'DistroArchSeriesBinaryPackageBreadcrumb',
44 'DistroArchSeriesBinaryPackageNavigation',
45 'DistroArchSeriesBinaryPackageView',
46 ]
47@@ -11,6 +12,15 @@
48 from lp.soyuz.interfaces.distroarchseriesbinarypackage import (
49 IDistroArchSeriesBinaryPackage)
50 from canonical.launchpad.webapp import ApplicationMenu, GetitemNavigation
51+from canonical.launchpad.webapp.breadcrumb import Breadcrumb
52+
53+
54+class DistroArchSeriesBinaryPackageBreadcrumb(Breadcrumb):
55+ """A breadcrumb for `DistroArchSeriesBinaryPackage`."""
56+
57+ @property
58+ def text(self):
59+ return self.context.name
60
61
62 class DistroArchSeriesBinaryPackageOverviewMenu(ApplicationMenu):
63
64=== modified file 'lib/lp/soyuz/browser/distroarchseriesbinarypackagerelease.py'
65--- lib/lp/soyuz/browser/distroarchseriesbinarypackagerelease.py 2009-06-25 04:06:00 +0000
66+++ lib/lp/soyuz/browser/distroarchseriesbinarypackagerelease.py 2009-09-02 16:30:48 +0000
67@@ -4,6 +4,7 @@
68 __metaclass__ = type
69
70 __all__ = [
71+ 'DistroArchSeriesBinaryPackageReleaseBreadcrumb',
72 'DistroArchSeriesBinaryPackageReleaseNavigation',
73 'DistroArchSeriesBinaryPackageReleaseView',
74 ]
75@@ -11,6 +12,15 @@
76 from lp.soyuz.interfaces.distroarchseriesbinarypackagerelease import (
77 IDistroArchSeriesBinaryPackageRelease)
78 from canonical.launchpad.webapp import ApplicationMenu, Navigation
79+from canonical.launchpad.webapp.breadcrumb import Breadcrumb
80+
81+
82+class DistroArchSeriesBinaryPackageReleaseBreadcrumb(Breadcrumb):
83+ """A breadcrumb for `DistroArchSeriesBinaryPackageRelease`."""
84+
85+ @property
86+ def text(self):
87+ return self.context.version
88
89
90 class DistroArchSeriesBinaryPackageReleaseOverviewMenu(ApplicationMenu):
91
92=== added file 'lib/lp/soyuz/browser/tests/test_breadcrumbs.py'
93--- lib/lp/soyuz/browser/tests/test_breadcrumbs.py 1970-01-01 00:00:00 +0000
94+++ lib/lp/soyuz/browser/tests/test_breadcrumbs.py 2009-09-02 16:32:06 +0000
95@@ -0,0 +1,59 @@
96+# Copyright 2009 Canonical Ltd. This software is licensed under the
97+# GNU Affero General Public License version 3 (see the file LICENSE).
98+
99+__metaclass__ = type
100+
101+import unittest
102+
103+from zope.component import getUtility
104+
105+from canonical.launchpad.webapp.publisher import canonical_url
106+from canonical.launchpad.webapp.tests.breadcrumbs import (
107+ BaseBreadcrumbTestCase)
108+from lp.registry.interfaces.distribution import IDistributionSet
109+
110+
111+class TestDistroArchSeriesBreadcrumb(BaseBreadcrumbTestCase):
112+
113+ def setUp(self):
114+ super(TestDistroArchSeriesBreadcrumb, self).setUp()
115+ self.ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
116+ self.hoary = self.ubuntu.getSeries('hoary')
117+ self.hoary_i386 = self.hoary['i386']
118+ self.traversed_objects = [
119+ self.root, self.ubuntu, self.hoary, self.hoary_i386]
120+
121+ def test_distroarchseries(self):
122+ das_url = canonical_url(self.hoary_i386)
123+ urls = self._getBreadcrumbsURLs(das_url, self.traversed_objects)
124+ texts = self._getBreadcrumbsTexts(das_url, self.traversed_objects)
125+
126+ self.assertEquals(urls[-1], das_url)
127+ self.assertEquals(texts[-1], "i386")
128+
129+ def test_distroarchseriesbinarypackage(self):
130+ pmount_hoary_i386 = self.hoary_i386.getBinaryPackage("pmount")
131+ self.traversed_objects.append(pmount_hoary_i386)
132+ pmount_url = canonical_url(pmount_hoary_i386)
133+ urls = self._getBreadcrumbsURLs(pmount_url, self.traversed_objects)
134+ texts = self._getBreadcrumbsTexts(pmount_url, self.traversed_objects)
135+
136+ self.assertEquals(urls[-1], pmount_url)
137+ self.assertEquals(texts[-1], "pmount")
138+
139+ def test_distroarchseriesbinarypackagerelease(self):
140+ pmount_hoary_i386 = self.hoary_i386.getBinaryPackage("pmount")
141+ pmount_release = pmount_hoary_i386['0.1-1']
142+ self.traversed_objects.extend([pmount_hoary_i386, pmount_release])
143+ pmount_release_url = canonical_url(pmount_release)
144+ urls = self._getBreadcrumbsURLs(
145+ pmount_release_url, self.traversed_objects)
146+ texts = self._getBreadcrumbsTexts(
147+ pmount_release_url, self.traversed_objects)
148+
149+ self.assertEquals(urls[-1], pmount_release_url)
150+ self.assertEquals(texts[-1], "0.1-1")
151+
152+
153+def test_suite():
154+ return unittest.TestLoader().loadTestsFromName(__name__)
155
156=== modified file 'lib/lp/soyuz/configure.zcml'
157--- lib/lp/soyuz/configure.zcml 2009-08-24 20:28:33 +0000
158+++ lib/lp/soyuz/configure.zcml 2009-09-02 16:30:48 +0000
159@@ -373,6 +373,12 @@
160 <allow
161 interface="lp.soyuz.interfaces.processor.IProcessorFamilySet"/>
162 </securedutility>
163+ <adapter
164+ for="lp.soyuz.interfaces.distroarchseriesbinarypackagerelease.IDistroArchSeriesBinaryPackageRelease"
165+ provides="canonical.launchpad.webapp.interfaces.IBreadcrumb"
166+ factory="lp.soyuz.browser.distroarchseriesbinarypackagerelease.DistroArchSeriesBinaryPackageReleaseBreadcrumb"
167+ permission="zope.Public" />
168+
169
170 <!-- Archive -->
171
172@@ -572,6 +578,11 @@
173 <allow
174 interface="lp.soyuz.interfaces.distroarchseriesbinarypackage.IDistroArchSeriesBinaryPackage"/>
175 </class>
176+ <adapter
177+ for="lp.soyuz.interfaces.distroarchseriesbinarypackage.IDistroArchSeriesBinaryPackage"
178+ provides="canonical.launchpad.webapp.interfaces.IBreadcrumb"
179+ factory="lp.soyuz.browser.distroarchseriesbinarypackage.DistroArchSeriesBinaryPackageBreadcrumb"
180+ permission="zope.Public" />
181
182 <!-- PublishedPackage -->
183
184@@ -678,6 +689,11 @@
185 permission="launchpad.Admin"
186 set_schema="lp.soyuz.interfaces.distroarchseries.IDistroArchSeries"/>
187 </class>
188+ <adapter
189+ for="lp.soyuz.interfaces.distroarchseries.IDistroArchSeries"
190+ provides="canonical.launchpad.webapp.interfaces.IBreadcrumb"
191+ factory="lp.soyuz.browser.distroarchseries.DistroArchSeriesBreadcrumb"
192+ permission="zope.Public" />
193 </facet>
194
195 <!-- DistroArchSeriesSet -->