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
=== modified file 'lib/lp/translations/browser/configure.zcml'
--- lib/lp/translations/browser/configure.zcml 2009-11-13 22:33:06 +0000
+++ lib/lp/translations/browser/configure.zcml 2009-12-07 19:05:37 +0000
@@ -69,10 +69,11 @@
69 layer="canonical.launchpad.layers.TranslationsLayer"/>69 layer="canonical.launchpad.layers.TranslationsLayer"/>
70 <browser:page70 <browser:page
71 for="*"71 for="*"
72 name="+translationmessage-macros"72 name="+translations-macros"
73 facet="translations"73 facet="translations"
74 permission="zope.Public"74 permission="zope.Public"
75 template="../templates/translationmessage-macros.pt"/>75 template="../templates/translations-macros.pt"
76 layer="canonical.launchpad.layers.TranslationsLayer"/>
76 <browser:page77 <browser:page
77 for="lp.translations.interfaces.translationgroup.IHasTranslationGroup"78 for="lp.translations.interfaces.translationgroup.IHasTranslationGroup"
78 facet="translations"79 facet="translations"
7980
=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-translate.txt'
--- lib/lp/translations/stories/standalone/xx-pofile-translate.txt 2009-07-01 20:45:39 +0000
+++ lib/lp/translations/stories/standalone/xx-pofile-translate.txt 2009-12-07 19:05:37 +0000
@@ -1,4 +1,7 @@
1= Translation Submissions =1
2
3Translation Submissions
4=======================
25
3This pagetest is used to check general behaviour of IPOFile translation6This pagetest is used to check general behaviour of IPOFile translation
4submissions.7submissions.
@@ -15,10 +18,11 @@
15xx-pofile-translate-performance.txt18xx-pofile-translate-performance.txt
1619
1720
18== Anonymous access ==21Anonymous access
22----------------
1923
20Anonymous users are able to browse translations, but not to change them through24Anonymous users are able to browse translations, but not to change them
21the translation form.25through the translation form.
2226
23 >>> browser.open(27 >>> browser.open(
24 ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'28 ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'
@@ -35,6 +39,22 @@
35 >>> for input in main_content.findAll('input'):39 >>> for input in main_content.findAll('input'):
36 ... print 'Found input:\n%s' % input40 ... print 'Found input:\n%s' % input
3741
42As an anynoymous user you will have access to the download and details
43pages for the pofile this message belongs to. The link to upload page
44should not be in that list.
45
46 >>> nav = find_tag_by_id(browser.contents, 'nav-pofile-subpages')
47 >>> print extract_text(nav)
48 Download translation Translation details
49
50Download translations and Translation details should linked to the proper
51pages
52
53 >> print nav.getLink("Download translation").url
54 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
55 >> print nav.getLink("Translation details").url
56 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
57
38Rendering the form in read-only mode does not actually stop an anonymous58Rendering the form in read-only mode does not actually stop an anonymous
39visitor (e.g. a spam bot, or a user whose login has expired) from submitting59visitor (e.g. a spam bot, or a user whose login has expired) from submitting
40data. That part is more convenience than security. The server does not60data. That part is more convenience than security. The server does not
@@ -53,7 +73,34 @@
53 our licensing terms cannot do POST submissions...73 our licensing terms cannot do POST submissions...
5474
5575
56== Requesting English and its variant languages ==76Translation Admin Access
77------------------------
78
79Let's log in.
80
81 >>> admin_browser.open(
82 ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'
83 ... 'evolution/+pots/evolution-2.2/es/+translate')
84
85As a translation admin you will have access to the download, upload
86and details pages for the pofile this message belongs to.
87
88 >>> nav = find_tag_by_id(admin_browser.contents, 'nav-pofile-subpages')
89 >>> print extract_text(nav)
90 Download translation Upload translation Translation details
91
92All those links should linked the proper pages
93
94 >> print nav.getLink("Download translation").url
95 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
96 >> print nav.getLink("Upload translation").url
97 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+upload
98 >> print nav.getLink("Translation details").url
99 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
100
101
102Requesting English and its variant languages
103--------------------------------------------
57104
58English is not translatable since we store the untranslated messages105English is not translatable since we store the untranslated messages
59as English. The translate view uses often uses two languages during106as English. The translate view uses often uses two languages during
@@ -77,7 +124,8 @@
77the 'make suggestions from' feature.124the 'make suggestions from' feature.
78125
79126
80== Form elements ==127Form elements
128-------------
81129
82Because the server does not remember what forms it served to whom, it is130Because the server does not remember what forms it served to whom, it is
83essential that every form element identifier provide all the context the131essential that every form element identifier provide all the context the
84132
=== modified file 'lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt'
--- lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt 2009-07-17 16:38:54 +0000
+++ lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt 2009-12-07 19:05:37 +0000
@@ -1,12 +1,20 @@
1
2Here is the story for translating a single message
3==================================================
4
1Here we are going to check the basic behaviour of the translation form when we5Here we are going to check the basic behaviour of the translation form when we
2render just one message with all available information for it.6render just one message with all available information for it.
37
8
9Getting there
10-------------
11
4First, we need to be sure that anonymous users are able to browse translations12First, we need to be sure that anonymous users are able to browse translations
5but are unable to actually change them.13but are unable to actually change them.
614
7 >>> browser.open(15 >>> browser.open(
8 ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/'16 ... 'http://translations.launchpad.dev/ubuntu/hoary/+source/'
9 ... '+pots/evolution-2.2/es/5')17 ... 'evolution/+pots/evolution-2.2/es/5')
1018
11We are in read only mode, so there shouldn't be any textareas:19We are in read only mode, so there shouldn't be any textareas:
1220
@@ -19,6 +27,22 @@
19 >>> for input in main_content.findAll('input'):27 >>> for input in main_content.findAll('input'):
20 ... raise AssertionError, 'Found input:\n%s' % input28 ... raise AssertionError, 'Found input:\n%s' % input
2129
30As an anynoymous user you will have access to the download and details
31pages for the pofile this message belongs to. The link to upload page
32should not be in that list.
33
34 >>> nav = find_tag_by_id(browser.contents, 'nav-pofile-subpages')
35 >>> print extract_text(nav)
36 Download translation Translation details
37
38Download translations and Translation details should linked to the proper
39pages
40
41 >> print nav.getLink("Download translation").url
42 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
43 >> print nav.getLink("Translation details").url
44 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
45
22Also, any anonymous POST submission should fail:46Also, any anonymous POST submission should fail:
2347
24 >>> print http(r"""48 >>> print http(r"""
@@ -125,6 +149,22 @@
125 >>> print browser.getLink('Last').url149 >>> print browser.getLink('Last').url
126 http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/22/+translate150 http://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/22/+translate
127151
152As a translation admin you will have access to the download, upload
153and details pages for the pofile this message belongs to.
154
155 >>> nav = find_tag_by_id(browser.contents, 'nav-pofile-subpages')
156 >>> print extract_text(nav)
157 Download translation Upload translation Translation details
158
159All those links should linked the proper pages
160
161 >> print nav.getLink("Download translation").url
162 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+export
163 >> print nav.getLink("Upload translation").url
164 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+upload
165 >> print nav.getLink("Translation details").url
166 https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+details
167
128Now, we are going to check a message submission.168Now, we are going to check a message submission.
129169
130 >>> browser.open(170 >>> browser.open(
@@ -384,7 +424,8 @@
384 ... 'msgset_143_es_suggestion_703_0').renderContents()424 ... 'msgset_143_es_suggestion_703_0').renderContents()
385 'foo!!'425 'foo!!'
386426
387== Unreviewed translations ==427Unreviewed translations
428-----------------------
388429
389If there is a message which has a translation, but no reviewer (eg. uploaded430If there is a message which has a translation, but no reviewer (eg. uploaded
390from a package), it only shows the translator, and not reviewer.431from a package), it only shows the translator, and not reviewer.
@@ -399,7 +440,8 @@
399 >>> print find_tag_by_id(browser.contents, "translated_and_reviewed_by")440 >>> print find_tag_by_id(browser.contents, "translated_and_reviewed_by")
400 None441 None
401442
402== Translating context ==443Translating context
444-------------------
403445
404Going to a translation page for a message with the context displays the446Going to a translation page for a message with the context displays the
405context.447context.
@@ -431,7 +473,9 @@
431 ... find_tag_by_id(browser.contents, "msgset_198_sr_translation_0"))473 ... find_tag_by_id(browser.contents, "msgset_198_sr_translation_0"))
432 blah474 blah
433475
434== Empty imported messages ==476
477Empty imported messages
478-----------------------
435479
436Empty messages coming from import are not shown as 'packaged' suggestions,480Empty messages coming from import are not shown as 'packaged' suggestions,
437even if we keep them to know when were they deactivated.481even if we keep them to know when were they deactivated.
@@ -491,7 +535,9 @@
491 >>> print packaged535 >>> print packaged
492 None536 None
493537
494== Shared and diverged translations ==538
539Shared and diverged translations
540--------------------------------
495541
496We create a POFile with one shared translation, which we want to diverge542We create a POFile with one shared translation, which we want to diverge
497from.543from.
498544
=== modified file 'lib/lp/translations/templates/currenttranslationmessage-translate-one.pt'
--- lib/lp/translations/templates/currenttranslationmessage-translate-one.pt 2009-07-17 18:46:25 +0000
+++ lib/lp/translations/templates/currenttranslationmessage-translate-one.pt 2009-12-07 19:05:37 +0000
@@ -393,7 +393,7 @@
393 user_is_official_translator view/user_is_official_translator;393 user_is_official_translator view/user_is_official_translator;
394 ">394 ">
395 <metal:suggestion395 <metal:suggestion
396 use-macro="context/@@+translationmessage-macros/render-suggestion" />396 use-macro="context/@@+translations-macros/render-suggestion" />
397 </tal:imported_translation>397 </tal:imported_translation>
398 <tal:shared_translation398 <tal:shared_translation
399 condition="translation_dictionary/shared_translation_message"399 condition="translation_dictionary/shared_translation_message"
@@ -405,7 +405,7 @@
405 user_is_official_translator view/user_is_official_translator;405 user_is_official_translator view/user_is_official_translator;
406 ">406 ">
407 <metal:suggestion407 <metal:suggestion
408 use-macro="context/@@+translationmessage-macros/render-suggestion" />408 use-macro="context/@@+translations-macros/render-suggestion" />
409 </tal:shared_translation>409 </tal:shared_translation>
410 <tal:locked condition="not:context/potmsgset/is_translation_credit">410 <tal:locked condition="not:context/potmsgset/is_translation_credit">
411 <tal:suggestions-title411 <tal:suggestions-title
412412
=== modified file 'lib/lp/translations/templates/pofile-translate.pt'
--- lib/lp/translations/templates/pofile-translate.pt 2009-12-03 18:33:22 +0000
+++ lib/lp/translations/templates/pofile-translate.pt 2009-12-07 19:05:37 +0000
@@ -142,21 +142,8 @@
142 </div>142 </div>
143143
144 <!-- Navigation -->144 <!-- Navigation -->
145 <ul class="horizontal" style="margin-top: 1em; margin-bottom: 1em;"145 <metal:nav-pofile-subpages
146 tal:define="navigation_menu context/menu:navigation">146 use-macro="context/@@+translations-macros/nav-pofile-subpages" />
147 <li
148 tal:define="link navigation_menu/download"
149 tal:condition="link/enabled"
150 tal:content="structure link/render"></li>
151 <li
152 tal:define="link navigation_menu/upload"
153 tal:condition="link/enabled"
154 tal:content="structure link/render"></li>
155 <li
156 tal:define="link navigation_menu/details"
157 tal:condition="link/enabled"
158 tal:content="structure link/render"></li>
159 </ul>
160147
161 <!-- View filter and suggestions from alternative language. -->148 <!-- View filter and suggestions from alternative language. -->
162 <form method="get" style="text-align: left;" action="+translate">149 <form method="get" style="text-align: left;" action="+translate">
163150
=== modified file 'lib/lp/translations/templates/translationmessage-suggestions.pt'
--- lib/lp/translations/templates/translationmessage-suggestions.pt 2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/translationmessage-suggestions.pt 2009-12-07 19:05:37 +0000
@@ -13,7 +13,7 @@
13 user_is_official_translator context/user_is_official_translator;13 user_is_official_translator context/user_is_official_translator;
14 ">14 ">
15 <metal:suggestion15 <metal:suggestion
16 use-macro="context/@@+translationmessage-macros/render-suggestion" />16 use-macro="context/@@+translations-macros/render-suggestion" />
17 </tal:variables>17 </tal:variables>
18 </tal:submission>18 </tal:submission>
19</tal:block>19</tal:block>
2020
=== modified file 'lib/lp/translations/templates/translationmessage-translate.pt'
--- lib/lp/translations/templates/translationmessage-translate.pt 2009-12-03 18:33:22 +0000
+++ lib/lp/translations/templates/translationmessage-translate.pt 2009-12-07 19:05:37 +0000
@@ -29,21 +29,8 @@
29 <tal:havepluralforms condition="view/has_plural_form_information">29 <tal:havepluralforms condition="view/has_plural_form_information">
3030
31 <!-- Navigation -->31 <!-- Navigation -->
32 <ul class="horizontal" style="margin-top: 1em; margin-bottom: 1em;"32 <metal:nav-pofile-subpages
33 tal:define="navigation_menu context/menu:navigation">33 use-macro="context/@@+translations-macros/nav-pofile-subpages" />
34 <li
35 tal:define="link navigation_menu/download"
36 tal:condition="link/enabled"
37 tal:content="structure link/render"></li>
38 <li
39 tal:define="link navigation_menu/upload"
40 tal:condition="link/enabled"
41 tal:content="structure link/render"></li>
42 <li
43 tal:define="link navigation_menu/details"
44 tal:condition="link/enabled"
45 tal:content="structure link/render"></li>
46 </ul>
4734
48 <!-- Alternative suggestions. -->35 <!-- Alternative suggestions. -->
49 <div metal:define-macro="editform">36 <div metal:define-macro="editform">
5037
=== renamed file 'lib/lp/translations/templates/translationmessage-macros.pt' => 'lib/lp/translations/templates/translations-macros.pt'
--- lib/lp/translations/templates/translationmessage-macros.pt 2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/translations-macros.pt 2009-12-07 19:05:37 +0000
@@ -3,7 +3,7 @@
3 xmlns:metal="http://xml.zope.org/namespaces/metal"3 xmlns:metal="http://xml.zope.org/namespaces/metal"
4 omit-tag="">4 omit-tag="">
55
6<metal:macro define-macro="render-suggestion">6<metal:render-suggestion define-macro="render-suggestion">
7<tal:submission condition="submission">7<tal:submission condition="submission">
8 <tal:not-empty condition="not:submission/is_empty">8 <tal:not-empty condition="not:submission/is_empty">
9 <tr tal:attributes="class string:secondary ${dismissable};9 <tr tal:attributes="class string:secondary ${dismissable};
@@ -105,7 +105,30 @@
105 </tal:not-empty>105 </tal:not-empty>
106</tal:submission>106</tal:submission>
107107
108</metal:macro>108</metal:render-suggestion>
109
110
111<metal:nav-pofile-subpages define-macro="nav-pofile-subpages">
112 <ul
113 class="horizontal"
114 id="nav-pofile-subpages"
115 style="margin-top: 1em; margin-bottom: 1em;"
116 tal:define="navigation_menu context/menu:navigation">
117 <li
118 tal:define="link navigation_menu/download"
119 tal:condition="link/enabled"
120 tal:content="structure link/render"></li>
121 <li
122 tal:define="link navigation_menu/upload"
123 tal:condition="link/enabled"
124 tal:content="structure link/render"></li>
125 <li
126 tal:define="link navigation_menu/details"
127 tal:condition="link/enabled"
128 tal:content="structure link/render"></li>
129 </ul>
130</metal:nav-pofile-subpages>
131
109132
110</tal:root>133</tal:root>
111134