Merge lp:~jtv/launchpad/bug-457987 into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jtv/launchpad/bug-457987
Merge into: lp:launchpad
Diff against target: 70 lines
2 files modified
lib/lp/translations/stories/standalone/xx-product-translations.txt (+31/-0)
lib/lp/translations/templates/product-translations.pt (+11/-6)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-457987
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+13774@code.launchpad.net

Commit message

Upload link on project page shown to users without upload privileges.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Bug 457987 =

The main Translations page for a project invites logged-in users to
download or upload translations. It should do the latter only for users
who are actually allowed to upload translations to the project. (There
may also be users who are allowed to upload translations to specific
languages in the project's translations, but they can't do that at this
level. They need to drill down to the POFile they want to upload to.)
We were getting some oopses from people following the upload link when
they weren't authorized to access the target page.

So here's the fix. As you can see the conditional tag surrounding all
this was once meant to show the link only to users with admin rights for
the project, but has changed into a check for logged-in users somewhere
along the line. I turned it into a span with an id for easier testing.

No lint. Test with {{{./bin/test -vv -t xx-product-translations.txt}}}
but might as well run all Translations stories if you have the few extra
minutes it takes. I did.

To Q/A, pick or set up a project that uses Launchpad for translations
and has at least an approved template. Then access its main
translations page anonymously (no upload or download links); as an owner
or admin or translations admin (upload and download links); and as a
regular user (download link only).

If you need to set up a template but don't have the Translations admin
rights needed to approve its import, note that you can now set up a
branch on staging and have your project import templates from there.
Push a template into that branch and within the hour you'll have it
uploaded, approved, and possibly even imported.

Jeroen

Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/translations/stories/standalone/xx-product-translations.txt'
--- lib/lp/translations/stories/standalone/xx-product-translations.txt 2009-09-17 12:59:41 +0000
+++ lib/lp/translations/stories/standalone/xx-product-translations.txt 2009-10-26 12:36:15 +0000
@@ -192,3 +192,34 @@
192 ...Translation overview...192 ...Translation overview...
193 >>> print_language_stats(anon_browser)193 >>> print_language_stats(anon_browser)
194 Language Untranslated Unreviewed Changed194 Language Untranslated Unreviewed Changed
195
196
197== Download and upload links ==
198
199A logged-in user is invited to download translations.
200
201 >>> def find_download_upload_invitation(browser):
202 ... """Find the text inviting the user to upload or download."""
203 ... tag = find_tag_by_id(browser.contents, 'downloadupload')
204 ... if tag is None:
205 ... return None
206 ... return extract_text(tag.renderContents())
207
208 >>> product_url = 'http://translations.launchpad.dev/evolution'
209
210 >>> user_browser.open(product_url)
211 >>> print find_download_upload_invitation(user_browser)
212 You can also download translations for trunk.
213
214An anonymous user does not see this invitation.
215
216 >>> anon_browser.open(product_url)
217 >>> print find_download_upload_invitation(anon_browser)
218 None
219
220A user with upload rights sees the invitation not just to download but
221to upload as well.
222
223 >>> admin_browser.open(product_url)
224 >>> print find_download_upload_invitation(admin_browser)
225 You can also download or upload translations for trunk.
195226
=== modified file 'lib/lp/translations/templates/product-translations.pt'
--- lib/lp/translations/templates/product-translations.pt 2009-09-25 17:21:00 +0000
+++ lib/lp/translations/templates/product-translations.pt 2009-10-26 12:36:15 +0000
@@ -27,16 +27,21 @@
27 Launchpad currently recommends translating27 Launchpad currently recommends translating
28 <tal:target replace="structure target/fmt:link"28 <tal:target replace="structure target/fmt:link"
29 >trunk</tal:target>.29 >trunk</tal:target>.
30 <tal:admins condition="context/required:launchpad.AnyPerson">30 <span id="downloadupload"
31 tal:condition="context/required:launchpad.AnyPerson">
31 You can also32 You can also
32 <a tal:attributes="href target/fmt:url/+export"33 <a tal:attributes="href target/fmt:url/+export"
33 >download</a> or34 >download</a>
34 <a tal:attributes="35 <tal:owner-or-admin condition="admin_user">
35 href target/fmt:url/+translations-upload"36 or
36 >upload</a> translations for37 <a tal:attributes="
38 href target/fmt:url/+translations-upload"
39 >upload</a>
40 </tal:owner-or-admin>
41 translations for
37 <tal:target replace="structure target/name"42 <tal:target replace="structure target/name"
38 >trunk</tal:target>.43 >trunk</tal:target>.
39 </tal:admins>44 </span>
40 </p>45 </p>
41 <p>To see all the translation files that are waiting to be46 <p>To see all the translation files that are waiting to be
42 imported, please look at47 imported, please look at