Merge lp://staging/~jtv/launchpad/bug-426078 into lp://staging/launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~jtv/launchpad/bug-426078
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~jtv/launchpad/bug-426078
Reviewer Review Type Date Requested Status
Gavin Panella (community) code Approve
Review via email: mp+11349@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Bug 426078 =

This behaviour was spec'ed during the Translations UI sprint in Buenos
Aires earlier this year.

When a user has not set their preferred languages, their personal
translations dashboard page should nag about it. This branch adds that
nag message, including a link to the page where the necessary change can
be made.

For reference, here is the message as it was _really_ specified:

    https://devpad.canonical.com/~danilo/pages/untranslator.jpg

I took the "dude" part with a grain of salt.

Tests:
{{{
./bin/test -vv -t person-editlanguages -t persontranslationview
}}}

No lint complaints.

Jeroen

Revision history for this message
Gavin Panella (allenap) :
review: Approve (code)
Revision history for this message
Gavin Panella (allenap) :
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/translations/browser/person.py'
2--- lib/lp/translations/browser/person.py 2009-09-03 12:49:12 +0000
3+++ lib/lp/translations/browser/person.py 2009-09-08 10:02:33 +0000
4@@ -182,6 +182,11 @@
5 else:
6 return user.inTeam(self.context)
7
8+ @property
9+ def requires_preferred_languages(self):
10+ """Does this person need to set preferred languages?"""
11+ return not self.context.isTeam() and len(self.context.languages) == 0
12+
13 def should_display_message(self, translationmessage):
14 """Should a certain `TranslationMessage` be displayed.
15
16
17=== modified file 'lib/lp/translations/browser/tests/test_persontranslationview.py'
18--- lib/lp/translations/browser/tests/test_persontranslationview.py 2009-09-03 15:20:28 +0000
19+++ lib/lp/translations/browser/tests/test_persontranslationview.py 2009-09-08 10:02:33 +0000
20@@ -352,6 +352,18 @@
21 descriptions = self.view.top_projects_and_packages_to_translate
22 self.assertEqual(10, len(descriptions))
23
24+ def test_requires_preferred_languages(self):
25+ # requires_preferred_languages tells the page whether this
26+ # person still needs to set their preferred languages.
27+ # In this case, our person has set a preferred language, so no,
28+ # this is no longer required.
29+ self.assertFalse(self.view.requires_preferred_languages)
30+
31+ # But the answer is True if the person has no preferred
32+ # languages.
33+ self.view.context.removeLanguage(self.dutch)
34+ self.assertTrue(self.view.requires_preferred_languages)
35+
36
37 def test_suite():
38 return TestLoader().loadTestsFromName(__name__)
39
40=== modified file 'lib/lp/translations/stories/standalone/xx-person-editlanguages.txt'
41--- lib/lp/translations/stories/standalone/xx-person-editlanguages.txt 2009-08-19 15:18:59 +0000
42+++ lib/lp/translations/stories/standalone/xx-person-editlanguages.txt 2009-09-08 10:02:33 +0000
43@@ -179,3 +179,59 @@
44 >>> for message in find_tags_by_class(admin_browser.contents, 'message'):
45 ... print extract_text(message)
46 Added Esperanto to No Privileges Person's preferred languages.
47+
48+
49+The personal page nags
50+----------------------
51+
52+If you don't have your preferred languages set, your Translations home
53+page will nag you about it.
54+
55+ >>> def find_nag(browser):
56+ ... """Return the nag message as shown in browser, if present."""
57+ ... tag = find_tag_by_id(browser.contents, 'no-languages')
58+ ... if tag:
59+ ... return tag.renderContents()
60+ ... else:
61+ ... return None
62+
63+Noi, a new user, visits her home page.
64+
65+ >>> login(ANONYMOUS)
66+ >>> noi = factory.makePerson(
67+ ... name='noi', email='noi@example.com', password='test')
68+ >>> logout()
69+
70+ >>> noi_browser = setupBrowser('Basic noi@example.com:test')
71+ >>> noi_home = 'http://translations.launchpad.dev/~noi'
72+ >>> noi_browser.open(noi_home)
73+
74+The home page reminds her to set her preferred languages.
75+
76+ >>> print find_nag(noi_browser)
77+ You have not selected your preferred languages.
78+ Please <a ...>set them now</a>.
79+
80+The message does not appear for other users looking at Noi's home page.
81+
82+ >>> user_browser.open(noi_home)
83+ >>> print find_nag(user_browser)
84+ None
85+
86+The nag message links to the languages editing page.
87+
88+ >>> noi_browser.getLink(id='set-languages').click()
89+ >>> print noi_browser.title
90+ Your language preferences
91+
92+Once Noi has set one or more preferred languages, the nag message goes
93+away.
94+
95+ >>> login(ANONYMOUS)
96+ >>> from lp.services.worlddata.model.language import LanguageSet
97+ >>> noi.addLanguage(LanguageSet().getLanguageByCode('lo'))
98+ >>> logout()
99+
100+ >>> noi_browser.open(noi_home)
101+ >>> print find_nag(noi_browser)
102+ None
103
104=== modified file 'lib/lp/translations/templates/person-translations.pt'
105--- lib/lp/translations/templates/person-translations.pt 2009-08-28 08:23:04 +0000
106+++ lib/lp/translations/templates/person-translations.pt 2009-09-08 10:02:33 +0000
107@@ -16,6 +16,10 @@
108 <h1>Translations related to <tal:name content="context/displayname" /></h1>
109
110 <tal:me condition="view/person_includes_me">
111+ <p tal:condition="view/requires_preferred_languages" id="no-languages">
112+ You have not selected your preferred languages. Please
113+ <a href="/+editmylanguages" id="set-languages">set them now</a>.
114+ </p>
115 <tal:reviewer condition="view/person_is_reviewer">
116 <div id="translations-to-review-section" style="max-width:800px">
117 <span style="float:right">