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
1=== modified file 'lib/lp/translations/stories/standalone/xx-product-translations.txt'
2--- lib/lp/translations/stories/standalone/xx-product-translations.txt 2009-09-17 12:59:41 +0000
3+++ lib/lp/translations/stories/standalone/xx-product-translations.txt 2009-10-26 12:36:15 +0000
4@@ -192,3 +192,34 @@
5 ...Translation overview...
6 >>> print_language_stats(anon_browser)
7 Language Untranslated Unreviewed Changed
8+
9+
10+== Download and upload links ==
11+
12+A logged-in user is invited to download translations.
13+
14+ >>> def find_download_upload_invitation(browser):
15+ ... """Find the text inviting the user to upload or download."""
16+ ... tag = find_tag_by_id(browser.contents, 'downloadupload')
17+ ... if tag is None:
18+ ... return None
19+ ... return extract_text(tag.renderContents())
20+
21+ >>> product_url = 'http://translations.launchpad.dev/evolution'
22+
23+ >>> user_browser.open(product_url)
24+ >>> print find_download_upload_invitation(user_browser)
25+ You can also download translations for trunk.
26+
27+An anonymous user does not see this invitation.
28+
29+ >>> anon_browser.open(product_url)
30+ >>> print find_download_upload_invitation(anon_browser)
31+ None
32+
33+A user with upload rights sees the invitation not just to download but
34+to upload as well.
35+
36+ >>> admin_browser.open(product_url)
37+ >>> print find_download_upload_invitation(admin_browser)
38+ You can also download or upload translations for trunk.
39
40=== modified file 'lib/lp/translations/templates/product-translations.pt'
41--- lib/lp/translations/templates/product-translations.pt 2009-09-25 17:21:00 +0000
42+++ lib/lp/translations/templates/product-translations.pt 2009-10-26 12:36:15 +0000
43@@ -27,16 +27,21 @@
44 Launchpad currently recommends translating
45 <tal:target replace="structure target/fmt:link"
46 >trunk</tal:target>.
47- <tal:admins condition="context/required:launchpad.AnyPerson">
48+ <span id="downloadupload"
49+ tal:condition="context/required:launchpad.AnyPerson">
50 You can also
51 <a tal:attributes="href target/fmt:url/+export"
52- >download</a> or
53- <a tal:attributes="
54- href target/fmt:url/+translations-upload"
55- >upload</a> translations for
56+ >download</a>
57+ <tal:owner-or-admin condition="admin_user">
58+ or
59+ <a tal:attributes="
60+ href target/fmt:url/+translations-upload"
61+ >upload</a>
62+ </tal:owner-or-admin>
63+ translations for
64 <tal:target replace="structure target/name"
65 >trunk</tal:target>.
66- </tal:admins>
67+ </span>
68 </p>
69 <p>To see all the translation files that are waiting to be
70 imported, please look at