Merge lp:~adiroiban/launchpad/bug-431249 into lp:launchpad

Proposed by Adi Roiban
Status: Merged
Approved by: Aaron Bentley
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~adiroiban/launchpad/bug-431249
Merge into: lp:launchpad
Diff against target: 365 lines (+142/-50)
8 files modified
lib/lp/translations/browser/configure.zcml (+3/-2)
lib/lp/translations/stories/standalone/xx-pofile-translate.txt (+54/-6)
lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt (+53/-7)
lib/lp/translations/templates/currenttranslationmessage-translate-one.pt (+2/-2)
lib/lp/translations/templates/pofile-translate.pt (+2/-15)
lib/lp/translations/templates/translationmessage-suggestions.pt (+1/-1)
lib/lp/translations/templates/translationmessage-translate.pt (+2/-15)
lib/lp/translations/templates/translations-macros.pt (+25/-2)
To merge this branch: bzr merge lp:~adiroiban/launchpad/bug-431249
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+15767@code.launchpad.net

Commit message

Create a macro for navigation links from pofile-translate.pt and translationmessage-translate.pt.

To post a comment you must log in.
Revision history for this message
Adi Roiban (adiroiban) wrote :

= Bug 431249 =

The templates pofile-translate.pt and translationmessage-translate.pt share the same set of navigation links so they should be factored out into their own macro file to be used by both.

== Proposed fix ==

A general +translations-macros view was creating for hosting translations macros.
The macro page hosting a single macro for translationmessage-translate.pt was renamed to a generic name.
The required pages were updated to the new macro path.

The macro required to fix this bug is hosted by translations-macros.pt

== Tests ==
I have added the required test in the required stories.

./bin/test -ct "translationmessage-translate" -t "pofile-translate"

Note: these tests are using the old formating style, but I left those change to have a clean diff.
If everthing is OK, after the review I can update the formating

== Demo and Q/A ==

For PO file go to this link:
http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate

For translation message go to this link:
http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/5

As an anonymous user or a user with no right for changing the translations you should only see the links to Download translation and Translation details

Translation admin / reviewer also have access to the upload page and they will see all links: Download translation, Upload translation and Translation details

= 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/translations/browser/configure.zcml
  lib/lp/translations/stories/standalone/xx-pofile-translate.txt
  lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt
  lib/lp/translations/templates/currenttranslationmessage-translate-one.pt
  lib/lp/translations/templates/pofile-translate.pt
  lib/lp/translations/templates/translationmessage-suggestions.pt
  lib/lp/translations/templates/translationmessage-translate.pt
  lib/lp/translations/templates/translations-macros.pt

Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/browser/configure.zcml'
2--- lib/lp/translations/browser/configure.zcml 2009-11-13 22:33:06 +0000
3+++ lib/lp/translations/browser/configure.zcml 2009-12-07 19:05:37 +0000
4@@ -69,10 +69,11 @@
5 layer="canonical.launchpad.layers.TranslationsLayer"/>
6 <browser:page
7 for="*"
8- name="+translationmessage-macros"
9+ name="+translations-macros"
10 facet="translations"
11 permission="zope.Public"
12- template="../templates/translationmessage-macros.pt"/>
13+ template="../templates/translations-macros.pt"
14+ layer="canonical.launchpad.layers.TranslationsLayer"/>
15 <browser:page
16 for="lp.translations.interfaces.translationgroup.IHasTranslationGroup"
17 facet="translations"
18
19=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-translate.txt'
20--- lib/lp/translations/stories/standalone/xx-pofile-translate.txt 2009-07-01 20:45:39 +0000
21+++ lib/lp/translations/stories/standalone/xx-pofile-translate.txt 2009-12-07 19:05:37 +0000
22@@ -1,4 +1,7 @@
23-= Translation Submissions =
24+
25+
26+Translation Submissions
27+=======================
28
29 This pagetest is used to check general behaviour of IPOFile translation
30 submissions.
31@@ -15,10 +18,11 @@
32 xx-pofile-translate-performance.txt
33
34
35-== Anonymous access ==
36+Anonymous access
37+----------------
38
39-Anonymous users are able to browse translations, but not to change them through
40-the translation form.
41+Anonymous users are able to browse translations, but not to change them
42+through the translation form.
43
44 >>> browser.open(
45 ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'
46@@ -35,6 +39,22 @@
47 >>> for input in main_content.findAll('input'):
48 ... print 'Found input:\n%s' % input
49
50+As an anynoymous user you will have access to the download and details
51+pages for the pofile this message belongs to. The link to upload page
52+should not be in that list.
53+
54+ >>> nav = find_tag_by_id(browser.contents, 'nav-pofile-subpages')
55+ >>> print extract_text(nav)
56+ Download translation Translation details
57+
58+Download translations and Translation details should linked to the proper
59+pages
60+
61+ >> print nav.getLink("Download translation").url
62+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
63+ >> print nav.getLink("Translation details").url
64+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
65+
66 Rendering the form in read-only mode does not actually stop an anonymous
67 visitor (e.g. a spam bot, or a user whose login has expired) from submitting
68 data. That part is more convenience than security. The server does not
69@@ -53,7 +73,34 @@
70 our licensing terms cannot do POST submissions...
71
72
73-== Requesting English and its variant languages ==
74+Translation Admin Access
75+------------------------
76+
77+Let's log in.
78+
79+ >>> admin_browser.open(
80+ ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'
81+ ... 'evolution/+pots/evolution-2.2/es/+translate')
82+
83+As a translation admin you will have access to the download, upload
84+and details pages for the pofile this message belongs to.
85+
86+ >>> nav = find_tag_by_id(admin_browser.contents, 'nav-pofile-subpages')
87+ >>> print extract_text(nav)
88+ Download translation Upload translation Translation details
89+
90+All those links should linked the proper pages
91+
92+ >> print nav.getLink("Download translation").url
93+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
94+ >> print nav.getLink("Upload translation").url
95+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+upload
96+ >> print nav.getLink("Translation details").url
97+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
98+
99+
100+Requesting English and its variant languages
101+--------------------------------------------
102
103 English is not translatable since we store the untranslated messages
104 as English. The translate view uses often uses two languages during
105@@ -77,7 +124,8 @@
106 the 'make suggestions from' feature.
107
108
109-== Form elements ==
110+Form elements
111+-------------
112
113 Because the server does not remember what forms it served to whom, it is
114 essential that every form element identifier provide all the context the
115
116=== modified file 'lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt'
117--- lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt 2009-07-17 16:38:54 +0000
118+++ lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt 2009-12-07 19:05:37 +0000
119@@ -1,12 +1,20 @@
120+
121+Here is the story for translating a single message
122+==================================================
123+
124 Here we are going to check the basic behaviour of the translation form when we
125 render just one message with all available information for it.
126
127+
128+Getting there
129+-------------
130+
131 First, we need to be sure that anonymous users are able to browse translations
132 but are unable to actually change them.
133
134- >>> browser.open(
135- ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/'
136- ... '+pots/evolution-2.2/es/5')
137+ >>> browser.open(
138+ ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'
139+ ... 'evolution/+pots/evolution-2.2/es/5')
140
141 We are in read only mode, so there shouldn't be any textareas:
142
143@@ -19,6 +27,22 @@
144 >>> for input in main_content.findAll('input'):
145 ... raise AssertionError, 'Found input:\n%s' % input
146
147+As an anynoymous user you will have access to the download and details
148+pages for the pofile this message belongs to. The link to upload page
149+should not be in that list.
150+
151+ >>> nav = find_tag_by_id(browser.contents, 'nav-pofile-subpages')
152+ >>> print extract_text(nav)
153+ Download translation Translation details
154+
155+Download translations and Translation details should linked to the proper
156+pages
157+
158+ >> print nav.getLink("Download translation").url
159+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
160+ >> print nav.getLink("Translation details").url
161+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
162+
163 Also, any anonymous POST submission should fail:
164
165 >>> print http(r"""
166@@ -125,6 +149,22 @@
167 >>> print browser.getLink('Last').url
168 http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/22/+translate
169
170+As a translation admin you will have access to the download, upload
171+and details pages for the pofile this message belongs to.
172+
173+ >>> nav = find_tag_by_id(browser.contents, 'nav-pofile-subpages')
174+ >>> print extract_text(nav)
175+ Download translation Upload translation Translation details
176+
177+All those links should linked the proper pages
178+
179+ >> print nav.getLink("Download translation").url
180+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
181+ >> print nav.getLink("Upload translation").url
182+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+upload
183+ >> print nav.getLink("Translation details").url
184+ https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
185+
186 Now, we are going to check a message submission.
187
188 >>> browser.open(
189@@ -384,7 +424,8 @@
190 ... 'msgset_143_es_suggestion_703_0').renderContents()
191 'foo!!'
192
193-== Unreviewed translations ==
194+Unreviewed translations
195+-----------------------
196
197 If there is a message which has a translation, but no reviewer (eg. uploaded
198 from a package), it only shows the translator, and not reviewer.
199@@ -399,7 +440,8 @@
200 >>> print find_tag_by_id(browser.contents, "translated_and_reviewed_by")
201 None
202
203-== Translating context ==
204+Translating context
205+-------------------
206
207 Going to a translation page for a message with the context displays the
208 context.
209@@ -431,7 +473,9 @@
210 ... find_tag_by_id(browser.contents, "msgset_198_sr_translation_0"))
211 blah
212
213-== Empty imported messages ==
214+
215+Empty imported messages
216+-----------------------
217
218 Empty messages coming from import are not shown as 'packaged' suggestions,
219 even if we keep them to know when were they deactivated.
220@@ -491,7 +535,9 @@
221 >>> print packaged
222 None
223
224-== Shared and diverged translations ==
225+
226+Shared and diverged translations
227+--------------------------------
228
229 We create a POFile with one shared translation, which we want to diverge
230 from.
231
232=== modified file 'lib/lp/translations/templates/currenttranslationmessage-translate-one.pt'
233--- lib/lp/translations/templates/currenttranslationmessage-translate-one.pt 2009-07-17 18:46:25 +0000
234+++ lib/lp/translations/templates/currenttranslationmessage-translate-one.pt 2009-12-07 19:05:37 +0000
235@@ -393,7 +393,7 @@
236 user_is_official_translator view/user_is_official_translator;
237 ">
238 <metal:suggestion
239- use-macro="context/@@+translationmessage-macros/render-suggestion" />
240+ use-macro="context/@@+translations-macros/render-suggestion" />
241 </tal:imported_translation>
242 <tal:shared_translation
243 condition="translation_dictionary/shared_translation_message"
244@@ -405,7 +405,7 @@
245 user_is_official_translator view/user_is_official_translator;
246 ">
247 <metal:suggestion
248- use-macro="context/@@+translationmessage-macros/render-suggestion" />
249+ use-macro="context/@@+translations-macros/render-suggestion" />
250 </tal:shared_translation>
251 <tal:locked condition="not:context/potmsgset/is_translation_credit">
252 <tal:suggestions-title
253
254=== modified file 'lib/lp/translations/templates/pofile-translate.pt'
255--- lib/lp/translations/templates/pofile-translate.pt 2009-12-03 18:33:22 +0000
256+++ lib/lp/translations/templates/pofile-translate.pt 2009-12-07 19:05:37 +0000
257@@ -142,21 +142,8 @@
258 </div>
259
260 <!-- Navigation -->
261- <ul class="horizontal" style="margin-top: 1em; margin-bottom: 1em;"
262- tal:define="navigation_menu context/menu:navigation">
263- <li
264- tal:define="link navigation_menu/download"
265- tal:condition="link/enabled"
266- tal:content="structure link/render"></li>
267- <li
268- tal:define="link navigation_menu/upload"
269- tal:condition="link/enabled"
270- tal:content="structure link/render"></li>
271- <li
272- tal:define="link navigation_menu/details"
273- tal:condition="link/enabled"
274- tal:content="structure link/render"></li>
275- </ul>
276+ <metal:nav-pofile-subpages
277+ use-macro="context/@@+translations-macros/nav-pofile-subpages" />
278
279 <!-- View filter and suggestions from alternative language. -->
280 <form method="get" style="text-align: left;" action="+translate">
281
282=== modified file 'lib/lp/translations/templates/translationmessage-suggestions.pt'
283--- lib/lp/translations/templates/translationmessage-suggestions.pt 2009-07-17 17:59:07 +0000
284+++ lib/lp/translations/templates/translationmessage-suggestions.pt 2009-12-07 19:05:37 +0000
285@@ -13,7 +13,7 @@
286 user_is_official_translator context/user_is_official_translator;
287 ">
288 <metal:suggestion
289- use-macro="context/@@+translationmessage-macros/render-suggestion" />
290+ use-macro="context/@@+translations-macros/render-suggestion" />
291 </tal:variables>
292 </tal:submission>
293 </tal:block>
294
295=== modified file 'lib/lp/translations/templates/translationmessage-translate.pt'
296--- lib/lp/translations/templates/translationmessage-translate.pt 2009-12-03 18:33:22 +0000
297+++ lib/lp/translations/templates/translationmessage-translate.pt 2009-12-07 19:05:37 +0000
298@@ -29,21 +29,8 @@
299 <tal:havepluralforms condition="view/has_plural_form_information">
300
301 <!-- Navigation -->
302- <ul class="horizontal" style="margin-top: 1em; margin-bottom: 1em;"
303- tal:define="navigation_menu context/menu:navigation">
304- <li
305- tal:define="link navigation_menu/download"
306- tal:condition="link/enabled"
307- tal:content="structure link/render"></li>
308- <li
309- tal:define="link navigation_menu/upload"
310- tal:condition="link/enabled"
311- tal:content="structure link/render"></li>
312- <li
313- tal:define="link navigation_menu/details"
314- tal:condition="link/enabled"
315- tal:content="structure link/render"></li>
316- </ul>
317+ <metal:nav-pofile-subpages
318+ use-macro="context/@@+translations-macros/nav-pofile-subpages" />
319
320 <!-- Alternative suggestions. -->
321 <div metal:define-macro="editform">
322
323=== renamed file 'lib/lp/translations/templates/translationmessage-macros.pt' => 'lib/lp/translations/templates/translations-macros.pt'
324--- lib/lp/translations/templates/translationmessage-macros.pt 2009-07-17 17:59:07 +0000
325+++ lib/lp/translations/templates/translations-macros.pt 2009-12-07 19:05:37 +0000
326@@ -3,7 +3,7 @@
327 xmlns:metal="http://xml.zope.org/namespaces/metal"
328 omit-tag="">
329
330-<metal:macro define-macro="render-suggestion">
331+<metal:render-suggestion define-macro="render-suggestion">
332 <tal:submission condition="submission">
333 <tal:not-empty condition="not:submission/is_empty">
334 <tr tal:attributes="class string:secondary ${dismissable};
335@@ -105,7 +105,30 @@
336 </tal:not-empty>
337 </tal:submission>
338
339-</metal:macro>
340+</metal:render-suggestion>
341+
342+
343+<metal:nav-pofile-subpages define-macro="nav-pofile-subpages">
344+ <ul
345+ class="horizontal"
346+ id="nav-pofile-subpages"
347+ style="margin-top: 1em; margin-bottom: 1em;"
348+ tal:define="navigation_menu context/menu:navigation">
349+ <li
350+ tal:define="link navigation_menu/download"
351+ tal:condition="link/enabled"
352+ tal:content="structure link/render"></li>
353+ <li
354+ tal:define="link navigation_menu/upload"
355+ tal:condition="link/enabled"
356+ tal:content="structure link/render"></li>
357+ <li
358+ tal:define="link navigation_menu/details"
359+ tal:condition="link/enabled"
360+ tal:content="structure link/render"></li>
361+ </ul>
362+</metal:nav-pofile-subpages>
363+
364
365 </tal:root>
366