Merge lp:~allenap/launchpad/fmt-link-for-distroseries-bug-425803 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/fmt-link-for-distroseries-bug-425803
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~allenap/launchpad/fmt-link-for-distroseries-bug-425803
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+11520@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Add a fmt TALES formatter specifically for IDistroSeries, and use it
in at least one place.

./bin/test -vvct 'cve-report|tales.txt'

Lint free (after removing line 2826 from tales.py).

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/canonical/launchpad/doc/tales.txt'
2--- lib/canonical/launchpad/doc/tales.txt 2009-09-04 13:46:47 +0000
3+++ lib/canonical/launchpad/doc/tales.txt 2009-09-10 10:49:44 +0000
4@@ -346,6 +346,8 @@
5 * blueprint-branch links
6 * projects
7 * questions
8+ * distributions
9+ * distroseries
10
11
12 Person entries
13@@ -647,6 +649,22 @@
14 u'<a... class="sprite question">1:...</a>'
15
16
17+Distributions
18+.............
19+
20+ >>> distribution = factory.makeDistribution()
21+ >>> test_tales("distribution/fmt:link", distribution=distribution)
22+ u'<a... class="sprite distribution">...</a>'
23+
24+
25+Distribution Series
26+...................
27+
28+ >>> distroseries = factory.makeDistroArchSeries().distroseries
29+ >>> test_tales("distroseries/fmt:link", distroseries=distroseries)
30+ u'<a href="...">...</a>'
31+
32+
33 The fmt: namespace for specially formatted object info
34 ------------------------------------------------------
35
36
37=== modified file 'lib/canonical/launchpad/webapp/configure.zcml'
38--- lib/canonical/launchpad/webapp/configure.zcml 2009-09-01 08:37:31 +0000
39+++ lib/canonical/launchpad/webapp/configure.zcml 2009-09-10 10:49:44 +0000
40@@ -365,6 +365,13 @@
41 />
42
43 <adapter
44+ for="lp.registry.interfaces.distroseries.IDistroSeries"
45+ provides="zope.traversing.interfaces.IPathAdapter"
46+ factory="canonical.launchpad.webapp.tales.DistroSeriesFormatterAPI"
47+ name="fmt"
48+ />
49+
50+ <adapter
51 for="canonical.launchpad.interfaces.IBug"
52 provides="zope.traversing.interfaces.IPathAdapter"
53 factory="canonical.launchpad.webapp.tales.BugFormatterAPI"
54
55=== modified file 'lib/canonical/launchpad/webapp/tales.py'
56--- lib/canonical/launchpad/webapp/tales.py 2009-09-07 12:16:29 +0000
57+++ lib/canonical/launchpad/webapp/tales.py 2009-09-10 12:39:52 +0000
58@@ -1215,6 +1215,17 @@
59 return html
60
61
62+class DistroSeriesFormatterAPI(CustomizableFormatter):
63+ """Adapter for IDistroSeries objects to a formatted string."""
64+
65+ _link_summary_template = '%(displayname)s'
66+ _link_permission = 'zope.Public'
67+
68+ def _link_summary_values(self):
69+ displayname = self._context.displayname
70+ return {'displayname': displayname}
71+
72+
73 class SourcePackageFormatterAPI(CustomizableFormatter):
74 """Adapter for ISourcePackage objects to a formatted string."""
75
76@@ -2812,7 +2823,6 @@
77 # Only linkify if person exists and does not want to hide
78 # their email addresses.
79 if person is not None and not person.hide_email_addresses:
80- person_formatter = PersonFormatterAPI(person)
81 css_sprite = ObjectImageDisplayAPI(person).sprite_css()
82 text = text.replace(
83 address, '<a href="%s" class="%s">&nbsp;%s</a>' % (
84
85=== modified file 'lib/lp/bugs/templates/distribution-cvereport.pt'
86--- lib/lp/bugs/templates/distribution-cvereport.pt 2009-09-07 09:39:50 +0000
87+++ lib/lp/bugs/templates/distribution-cvereport.pt 2009-09-10 12:32:50 +0000
88@@ -43,10 +43,8 @@
89 </tal:no_series>
90 <tal:series condition="serieses">
91 <ul>
92- <li tal:repeat="series serieses">
93- <a tal:attributes="href series/fmt:url/+cve"
94- tal:content="series/displayname" />
95- </li>
96+ <li tal:repeat="series serieses"
97+ tal:content="structure series/fmt:link/+cve" />
98 </ul>
99 </tal:series>
100 </div>