Merge lp:~wgrant/launchpad/dsp-translations into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 17257
Proposed branch: lp:~wgrant/launchpad/dsp-translations
Merge into: lp:launchpad
Diff against target: 192 lines (+143/-2)
6 files modified
lib/lp/registry/browser/distributionsourcepackage.py (+1/-0)
lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt (+1/-1)
lib/lp/translations/browser/configure.zcml (+14/-1)
lib/lp/translations/browser/distributionsourcepackage.py (+47/-0)
lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt (+29/-0)
lib/lp/translations/templates/distributionsourcepackage-translations.pt (+51/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/dsp-translations
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+242736@code.launchpad.net

Commit message

Give DistributionSourcePackage a basic +translations.

Description of the change

Currently one can only navigate to a SourcePackage's Translations facet by first visiting a linked ProductSeries or another facet of the SourcePackage. DSP was also unique in that it had no Translations facet despite its subordinate SourcePackage having one.

Since we're about to remove the ability to switch between a SourcePackage's facets using the facet menu, I've added a DistributionSourcePackage:+translations which recommends a SourcePackage:+translations.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
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/distributionsourcepackage.py'
2--- lib/lp/registry/browser/distributionsourcepackage.py 2014-11-24 01:20:26 +0000
3+++ lib/lp/registry/browser/distributionsourcepackage.py 2014-11-25 06:24:32 +0000
4@@ -117,6 +117,7 @@
5 'overview',
6 'branches',
7 'bugs',
8+ 'translations',
9 'answers',
10 ]
11
12
13=== modified file 'lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt'
14--- lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt 2014-11-09 21:58:40 +0000
15+++ lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt 2014-11-25 06:24:32 +0000
16@@ -51,7 +51,7 @@
17 * Code - http://code.launchpad.dev/ubuntutest/+source/testing-dspr
18 * Bugs - http://bugs.launchpad.dev/ubuntutest/+source/testing-dspr
19 * Blueprints - not linked
20- * Translations - not linked
21+ * Translations - http://translations.launchpad.dev/ubuntutest/+source/testing-dspr
22 * Answers - http://answers.launchpad.dev/ubuntutest/+source/testing-dspr
23 Main heading: ?testing-dspr? 1.0 source package in ubuntutest
24
25
26=== modified file 'lib/lp/translations/browser/configure.zcml'
27--- lib/lp/translations/browser/configure.zcml 2014-07-02 05:40:09 +0000
28+++ lib/lp/translations/browser/configure.zcml 2014-11-25 06:24:32 +0000
29@@ -475,7 +475,20 @@
30 permission="launchpad.AnyPerson"
31 template="../templates/translationmessage-suggestions.pt"/>
32
33-<!-- SourcePackage translation pages -->
34+ <!-- DistributionSourcePackage translation pages -->
35+
36+ <browser:defaultView
37+ for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage"
38+ name="+translations"
39+ layer="lp.translations.publisher.TranslationsLayer"/>
40+ <browser:page
41+ for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage"
42+ name="+translations"
43+ class="lp.translations.browser.distributionsourcepackage.DistributionSourcePackageView"
44+ permission="zope.Public"
45+ template="../templates/distributionsourcepackage-translations.pt"/>
46+
47+ <!-- SourcePackage translation pages -->
48
49 <browser:defaultView
50 for="lp.registry.interfaces.sourcepackage.ISourcePackage"
51
52=== added file 'lib/lp/translations/browser/distributionsourcepackage.py'
53--- lib/lp/translations/browser/distributionsourcepackage.py 1970-01-01 00:00:00 +0000
54+++ lib/lp/translations/browser/distributionsourcepackage.py 2014-11-25 06:24:32 +0000
55@@ -0,0 +1,47 @@
56+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
57+# GNU Affero General Public License version 3 (see the file LICENSE).
58+
59+"""Translations browser views for DistributionSourcePackages."""
60+
61+__metaclass__ = type
62+
63+__all__ = [
64+ 'DistributionSourcePackageView',
65+ ]
66+
67+import operator
68+
69+from lp.registry.interfaces.series import SeriesStatus
70+from lp.services.propertycache import cachedproperty
71+from lp.services.webapp.publisher import LaunchpadView
72+
73+
74+class DistributionSourcePackageView(LaunchpadView):
75+ """Default DistributionSourcePackage translations view class."""
76+
77+ @cachedproperty
78+ def translation_focus(self):
79+ """Return the ISourcePackage where the translators should work.
80+
81+ If ther isn't a defined focus, we return latest series.
82+ """
83+ series = (
84+ self.context.distribution.translation_focus
85+ or self.context.distribution.currentseries)
86+ if series is not None:
87+ return series.getSourcePackage(self.context.sourcepackagename)
88+
89+ def secondary_translatable_series(self):
90+ """Return a list of ISourcePackages that aren't the translation_focus.
91+
92+ It only includes the ones that are still supported.
93+ """
94+ series = [
95+ series.getSourcePackage(self.context.sourcepackagename)
96+ for series in self.context.distribution.series
97+ if (series.status != SeriesStatus.OBSOLETE
98+ and (self.translation_focus is None or
99+ self.translation_focus.distroseries != series))]
100+
101+ return sorted(series, key=operator.attrgetter('distroseries.version'),
102+ reverse=True)
103
104=== added file 'lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt'
105--- lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt 1970-01-01 00:00:00 +0000
106+++ lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt 2014-11-25 06:24:32 +0000
107@@ -0,0 +1,29 @@
108+= DistributionSourcePackage translations =
109+
110+This page directs users to SourcePackage translations pages.
111+
112+ >>> anon_browser.open(
113+ ... 'http://translations.launchpad.dev/ubuntu/+source/evolution')
114+ >>> anon_browser.title
115+ 'Translations : ...evolution...package : Ubuntu'
116+
117+ >>> content = find_main_content(anon_browser.contents)
118+ >>> print extract_text(content.find(attrs='top-portlet'))
119+ Launchpad currently recommends translating evolution in Ubuntu Hoary.
120+
121+The focus' two templates are shown.
122+
123+ >>> template_names = content.findAll('h2')
124+ >>> for name in template_names:
125+ ... print extract_text(name)
126+ Template "evolution-2.2" in Ubuntu Hoary package "evolution"
127+ Template "man" in Ubuntu Hoary package "evolution"
128+ Other versions of evolution in Ubuntu
129+
130+Other series are also listed.
131+
132+ >>> for other in content.find(id='distroseries-list').findAll('li'):
133+ ... print extract_text(other)
134+ Breezy Badger Autotest (6.6.6)
135+ Grumpy (5.10)
136+ Warty (4.10)
137
138=== added file 'lib/lp/translations/templates/distributionsourcepackage-translations.pt'
139--- lib/lp/translations/templates/distributionsourcepackage-translations.pt 1970-01-01 00:00:00 +0000
140+++ lib/lp/translations/templates/distributionsourcepackage-translations.pt 2014-11-25 06:24:32 +0000
141@@ -0,0 +1,51 @@
142+<html
143+ xmlns="http://www.w3.org/1999/xhtml"
144+ xmlns:tal="http://xml.zope.org/namespaces/tal"
145+ xmlns:metal="http://xml.zope.org/namespaces/metal"
146+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
147+ metal:use-macro="view/macro:page/main_only">
148+ <body>
149+ <div metal:fill-slot="main">
150+ <div class="translation-help-links">
151+ <a href="https://help.launchpad.net/Translations"
152+ id="link-to-translations-help"
153+ >Help for translations
154+ </a>
155+ <div></div><!-- to clear-up all floats -->
156+ </div>
157+
158+ <tal:translation_focus condition="view/translation_focus"
159+ define="target view/translation_focus">
160+
161+ <div class="top-portlet">
162+ Launchpad currently recommends translating
163+ <tal:target replace="structure target/fmt:link/+translations"
164+ >trunk</tal:target>.
165+ </div>
166+ <div tal:replace="structure view/translation_focus/@@+potlist" />
167+ </tal:translation_focus>
168+
169+ <tal:secondary condition="view/secondary_translatable_series">
170+ <h2 tal:condition="view/translation_focus">
171+ Other versions of <span tal:replace="context/displayname">Ubuntu</span>
172+ </h2>
173+
174+ <ul id="distroseries-list">
175+ <li tal:repeat="sourcepackage view/secondary_translatable_series">
176+ <a tal:attributes="href sourcepackage/fmt:url:translations"
177+ tal:content="sourcepackage/distroseries/named_version">Hoary (5.04)</a>
178+ </li>
179+ </ul>
180+ </tal:secondary>
181+
182+ <tal:untranslatable condition="not: view/translation_focus">
183+ <p>
184+ This package does not have any series to be translated. Once
185+ <span tal:replace="context/displayname">Ubuntu</span> has
186+ created a distroseries, you will be able to find or create
187+ translations for its packages here.
188+ </p>
189+ </tal:untranslatable>
190+</div>
191+</body>
192+</html>