Merge lp:~sinzui/launchpad/headings-and-words-0 into lp:launchpad

Proposed by Curtis Hovey on 2010-11-11
Status: Merged
Merged at revision: 11919
Proposed branch: lp:~sinzui/launchpad/headings-and-words-0
Merge into: lp:launchpad
Diff against target: 363 lines (+127/-84)
9 files modified
lib/lp/registry/browser/team.py (+2/-0)
lib/lp/registry/browser/tests/product-portlet-packages-view.txt (+6/-4)
lib/lp/registry/browser/tests/test_product.py (+37/-5)
lib/lp/registry/browser/tests/test_team.py (+70/-1)
lib/lp/registry/stories/product/xx-product-index.txt (+2/-2)
lib/lp/registry/stories/teammembership/xx-add-member.txt (+0/-67)
lib/lp/registry/templates/person-editpgpkeys.pt (+6/-2)
lib/lp/registry/templates/product-new.pt (+3/-2)
lib/lp/registry/templates/product-portlet-packages.pt (+1/-1)
To merge this branch: bzr merge lp:~sinzui/launchpad/headings-and-words-0
Reviewer Review Type Date Requested Status
Abel Deuring (community) code 2010-11-11 Approve on 2010-11-12
Review via email: mp+40677@code.launchpad.net

Description of the Change

This is my branch to fix some text issues in Launchpad registry pages.

    lp:~sinzui/launchpad/headings-and-words-0
    Diff size:
    Launchpad bug:
        https://bugs.launchpad.net/bugs/652039
        https://bugs.launchpad.net/bugs/282980
        https://bugs.launchpad.net/bugs/672735
        https://bugs.launchpad.net/bugs/244553
    Test command: ./bin/test -vv \
        -t product-portlet-packages-view -t xx-product-index \
        -t TestProductAddView \
        -t TestTeamMemberAddView -t xx-add-member
    Pre-implementation: No one
    Target release: 10.11

Fix some text issues in Launchpad registry pages
-------------------------------------------------

652039 Project page implies "Squeeze" and "Lenny" are Ubuntu version
    The "Packages in Distributions" portlet was changed to say "Ubuntu"
    to support the Ubuntu suggestions feature. But the listing of
    packages can always includes debian packages.

282980 Register project suggests that I use staging when I am using staging
    This is a regressing. We lot the is_demo check

672735 odd phrasing on +editgpgkeys
    The phrasing about deactivating a key does not clearly state that this
    only affects Launchpad.

244553 "New member" field is confusingly pre-filled after use
    After adding a member, the form is redisplayed with the new member field
    prefilled with the new member. The field should be cleared so that the
    form can be reused.

Rules
-----

652039 Project page implies "Squeeze" and "Lenny" are Ubuntu version
    Change portlet heading back to Distributions. The Ubuntu suggestions
    feature is not contradictory.

282980 Register project suggests that I use staging when I am using staging
    Add an is_demo check to the template and a tests to ensure it is not
    lost again

672735 odd phrasing on +editgpgkeys
    Used the proposed text which clearly states deactivating a key only
    affects Launchpad.

244553 "New member" field is confusingly pre-filled after use
    I wanted to set the next_url to the team page, but users still use
    the form to add members in succession. The action must reset the widget's
    value so that the field is ready to be reused.

QA
--

652039 Project page implies "Squeeze" and "Lenny" are Ubuntu version
    * Visit https://launchpad.net/bzr
    * Verify the portlet says "Packages in Distributions":

282980 Register project suggests that I use staging when I am using staging
    * visit staging.launchpad.net/projects/+new
    * Verify you are not direct to register test projects on staging.

672735 odd phrasing on +editgpgkeys
    * Visit your +editgpgkeys and verify this text:
      Note: deactivating a key in Launchpad disables all Launchpad features
      that use that key such as signed codes of conduct. Deactivating the key
      in Launchpad does not alter the key outside of Launchpad.

244553 "New member" field is confusingly pre-filled after use
    * Visit the +addmember form for a team you admin.
    * Add a member
    * Verify the notification says the user was added and that the field
      is empty.

Lint
----

Linting changed files:
  lib/lp/registry/browser/team.py
  lib/lp/registry/browser/tests/product-portlet-packages-view.txt
  lib/lp/registry/browser/tests/test_product.py
  lib/lp/registry/browser/tests/test_team.py
  lib/lp/registry/stories/product/xx-product-index.txt
  lib/lp/registry/stories/teammembership/xx-add-member.txt
  lib/lp/registry/templates/person-editpgpkeys.pt
  lib/lp/registry/templates/product-new.pt
  lib/lp/registry/templates/product-portlet-packages.pt

Test and Implementation
-----------------------

652039 Project page implies "Squeeze" and "Lenny" are Ubuntu version
    Used find and replace to restore "Packages in Distributions"
    * lib/lp/registry/browser/tests/product-portlet-packages-view.txt
    * lib/lp/registry/stories/product/xx-product-index.txt
    * lib/lp/registry/templates/product-portlet-packages.pt

282980 Register project suggests that I use staging when I am using staging
    Added a test to verify the staging message is not shown when registering
    a project on staging.
    * lib/lp/registry/browser/tests/test_product.py
    * lib/lp/registry/templates/product-new.pt

672735 odd phrasing on +editgpgkeys
    Revised the sentence.
    * lib/lp/registry/templates/person-editpgpkeys.pt

244553 "New member" field is confusingly pre-filled after use
    Added a test to verify that the newmember field is cleared when a member
    is added, then updated the view code. Converted 3 bad stories into
    unittests.
    * lib/lp/registry/browser/tests/test_team.py
    * lib/lp/registry/stories/teammembership/xx-add-member.txt
    * lib/lp/registry/browser/team.py

To post a comment you must log in.
Abel Deuring (adeuring) wrote :

nice work

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/registry/browser/team.py'
2--- lib/lp/registry/browser/team.py 2010-11-01 20:39:17 +0000
3+++ lib/lp/registry/browser/team.py 2010-11-11 23:06:43 +0000
4@@ -1075,6 +1075,8 @@
5 msg = "%s has been added as a member of this team." % (
6 newmember.unique_displayname)
7 self.request.response.addInfoNotification(msg)
8+ # Clear the newmember widget so that the user can add another member.
9+ self.widgets['newmember'].setRenderedValue(None)
10
11
12 class TeamMapView(LaunchpadView):
13
14=== modified file 'lib/lp/registry/browser/tests/product-portlet-packages-view.txt'
15--- lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-10-19 18:44:31 +0000
16+++ lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-11-11 23:06:43 +0000
17@@ -51,7 +51,9 @@
18 >>> print view.suggestions
19 []
20
21-The view does not set focus to its form otherwise it will cause the page to scroll.
22+The view does not set focus to its form otherwise it will cause the page to
23+scroll.
24+
25 >>> view.focusedElementScript()
26 ''
27
28@@ -61,7 +63,7 @@
29 >>> content = find_tag_by_id(view.render(), 'portlet-packages')
30 >>> print extract_text(content)
31 All packages
32- Packages in Ubuntu
33+ Packages in Distributions
34 Launchpad doesn't know which Ubuntu packages this project
35 provides. Links from distribution packages to upstream projects
36 let distribution and upstream maintainers share bugs, patches, and
37@@ -142,7 +144,7 @@
38
39 >>> print extract_text(content)
40 All packages
41- Packages in Ubuntu
42+ Packages in Distributions
43 Launchpad doesn't know which Ubuntu packages this project
44 provides. Links from distribution packages to upstream projects
45 let distribution and upstream maintainers share bugs, patches, and
46@@ -185,7 +187,7 @@
47 >>> content = find_tag_by_id(view.render(), 'portlet-packages')
48 >>> print extract_text(content)
49 All packages
50- Packages in Ubuntu
51+ Packages in Distributions
52 Launchpad doesn't know which Ubuntu packages this project
53 provides. Links from distribution packages to upstream projects
54 let distribution and upstream maintainers share bugs, patches, and
55
56=== modified file 'lib/lp/registry/browser/tests/test_product.py'
57--- lib/lp/registry/browser/tests/test_product.py 2010-10-25 20:20:45 +0000
58+++ lib/lp/registry/browser/tests/test_product.py 2010-11-11 23:06:43 +0000
59@@ -6,22 +6,31 @@
60 __metaclass__ = type
61
62 import datetime
63-import unittest
64
65 import pytz
66+
67+from zope.component import getUtility
68 from zope.security.proxy import removeSecurityProxy
69
70+from canonical.config import config
71+from canonical.launchpad.testing.pages import find_tag_by_id
72 from canonical.testing.layers import DatabaseFunctionalLayer
73 from lp.app.enums import ServiceUsage
74 from lp.registry.browser.product import ProductLicenseMixin
75-from lp.registry.interfaces.product import License
76+from lp.registry.interfaces.product import (
77+ License,
78+ IProductSet,
79+ )
80 from lp.testing import (
81 login_person,
82 TestCaseWithFactory,
83 )
84 from lp.testing.mail_helpers import pop_notifications
85 from lp.testing.service_usage_helpers import set_service_usage
86-from lp.testing.views import create_view
87+from lp.testing.views import (
88+ create_initialized_view,
89+ create_view,
90+ )
91
92
93 class TestProductLicenseMixin(TestCaseWithFactory):
94@@ -135,5 +144,28 @@
95 self.assertTrue(view.registration_done)
96
97
98-def test_suite():
99- return unittest.TestLoader().loadTestsFromName(__name__)
100+class TestProductAddView(TestCaseWithFactory):
101+ """Tests the configuration links and helpers."""
102+
103+ layer = DatabaseFunctionalLayer
104+
105+ def setUp(self):
106+ super(TestProductAddView, self).setUp()
107+ self.product_set = getUtility(IProductSet)
108+ # Marker allowing us to reset the config.
109+ config.push(self.id(), '')
110+ self.addCleanup(config.pop, self.id())
111+
112+ def test_staging_message_is_not_demo(self):
113+ view = create_initialized_view(self.product_set, '+new')
114+ message = find_tag_by_id(view.render(), 'staging-message')
115+ self.assertTrue(message is not None)
116+
117+ def test_staging_message_is_demo(self):
118+ config.push('staging-test', '''
119+ [launchpad]
120+ is_demo: true
121+ ''')
122+ view = create_initialized_view(self.product_set, '+new')
123+ message = find_tag_by_id(view.render(), 'staging-message')
124+ self.assertEqual(None, message)
125
126=== modified file 'lib/lp/registry/browser/tests/test_team.py'
127--- lib/lp/registry/browser/tests/test_team.py 2010-10-04 19:50:45 +0000
128+++ lib/lp/registry/browser/tests/test_team.py 2010-11-11 23:06:43 +0000
129@@ -5,7 +5,11 @@
130
131 from canonical.testing.layers import DatabaseFunctionalLayer
132 from lp.registry.browser.person import TeamOverviewMenu
133-from lp.testing import TestCaseWithFactory
134+from lp.testing import (
135+ login_person,
136+ TestCaseWithFactory,
137+ person_logged_in,
138+ )
139 from lp.testing.matchers import IsConfiguredBatchNavigator
140 from lp.testing.menu import check_menu_links
141 from lp.testing.views import create_initialized_view
142@@ -50,3 +54,68 @@
143 self.assertThat(
144 view.held_messages,
145 IsConfiguredBatchNavigator('message', 'messages'))
146+
147+
148+class TestTeamMemberAddView(TestCaseWithFactory):
149+
150+ layer = DatabaseFunctionalLayer
151+
152+ def setUp(self):
153+ super(TestTeamMemberAddView, self).setUp()
154+ self.team = self.factory.makeTeam(name='test-team')
155+ login_person(self.team.teamowner)
156+
157+ def getForm(self, new_member):
158+ return {
159+ 'field.newmember': new_member.name,
160+ 'field.actions.add': 'Add Member',
161+ }
162+
163+ def test_add_member_success(self):
164+ member = self.factory.makePerson(name="a-member")
165+ form = self.getForm(member)
166+ view = create_initialized_view(self.team, "+addmember", form=form)
167+ self.assertEqual([], view.errors)
168+ notifications = view.request.response.notifications
169+ self.assertEqual(1, len(notifications))
170+ self.assertEqual(
171+ 'A-member (a-member) has been added as a member of this team.',
172+ notifications[0].message)
173+ self.assertTrue(member.inTeam(self.team))
174+ self.assertEqual(
175+ None, view.widgets['newmember']._getCurrentValue())
176+
177+ def test_add_former_member_success(self):
178+ member = self.factory.makePerson(name="a-member")
179+ self.team.addMember(member, self.team.teamowner)
180+ with person_logged_in(member):
181+ member.leave(self.team)
182+ form = self.getForm(member)
183+ view = create_initialized_view(self.team, "+addmember", form=form)
184+ self.assertEqual([], view.errors)
185+ notifications = view.request.response.notifications
186+ self.assertEqual(1, len(notifications))
187+ self.assertEqual(
188+ 'A-member (a-member) has been added as a member of this team.',
189+ notifications[0].message)
190+ self.assertTrue(member.inTeam(self.team))
191+
192+ def test_add_existing_member_fail(self):
193+ member = self.factory.makePerson(name="a-member")
194+ self.team.addMember(member, self.team.teamowner)
195+ form = self.getForm(member)
196+ view = create_initialized_view(self.team, "+addmember", form=form)
197+ self.assertEqual(1, len(view.errors))
198+ self.assertEqual(
199+ "A-member (a-member) is already a member of Test Team.",
200+ view.errors[0])
201+
202+ def test_add_empty_team_fail(self):
203+ empty_team = self.factory.makeTeam(owner=self.team.teamowner)
204+ self.team.teamowner.leave(empty_team)
205+ form = self.getForm(empty_team)
206+ view = create_initialized_view(self.team, "+addmember", form=form)
207+ self.assertEqual(1, len(view.errors))
208+ self.assertEqual(
209+ "You can't add a team that doesn't have any active members.",
210+ view.errors[0])
211
212=== modified file 'lib/lp/registry/stories/product/xx-product-index.txt'
213--- lib/lp/registry/stories/product/xx-product-index.txt 2010-10-09 16:36:22 +0000
214+++ lib/lp/registry/stories/product/xx-product-index.txt 2010-11-11 23:06:43 +0000
215@@ -359,7 +359,7 @@
216 >>> print extract_text(
217 ... find_tag_by_id(user_browser.contents, 'portlet-packages'))
218 All packages
219- Packages in Ubuntu
220+ Packages in Distributions
221 “mozilla-firefox” source package in Warty Version 0.9 uploaded on...
222
223 A product that has linked packages now displays suggestions and asks
224@@ -372,7 +372,7 @@
225 >>> print extract_text(
226 ... find_tag_by_id(user_browser.contents, 'portlet-packages'))
227 All packages...
228- Packages in Ubuntu...
229+ Packages in Distributions...
230 Ubuntu Hoary packages:
231 pmount...
232
233
234=== modified file 'lib/lp/registry/stories/teammembership/xx-add-member.txt'
235--- lib/lp/registry/stories/teammembership/xx-add-member.txt 2010-10-09 16:36:22 +0000
236+++ lib/lp/registry/stories/teammembership/xx-add-member.txt 2010-11-11 23:06:43 +0000
237@@ -30,40 +30,6 @@
238 >>> cprov.inTeam(landscape_team)
239 True
240
241-If the new member is already an approved member of that team, we'll say that.
242-
243- >>> browser.url
244- 'http://launchpad.dev/%7Elandscape-developers/+addmember'
245- >>> browser.getControl('New member').value = 'cprov'
246- >>> browser.getControl('Add Member').click()
247-
248- >>> for tag in find_tags_by_class(browser.contents, 'message'):
249- ... print tag.renderContents()
250- There is 1 error.
251- Celso Providelo (cprov) is already a member of Landscape Developers.
252-
253-On the other hand, if the member is among the inactive/proposed members of
254-the team, we'll simply change the membership's status and say that it was
255-successfully added.
256-
257- >>> from lp.registry.interfaces.teammembership import TeamMembershipStatus
258- >>> from canonical.launchpad.ftests import ANONYMOUS, login, logout
259- >>> login(ANONYMOUS) # login() because we need a zope interaction.
260- >>> ignored = cprov_landscape_membership.setStatus(
261- ... TeamMembershipStatus.DEACTIVATED, landscape_team.teamowner)
262- >>> logout()
263- >>> cprov_landscape_membership.syncUpdate()
264-
265- >>> browser.url
266- 'http://launchpad.dev/%7Elandscape-developers/+addmember'
267- >>> browser.getControl('New member').value = 'cprov'
268- >>> browser.getControl('Add Member').click()
269-
270- >>> for tag in find_tags_by_class(browser.contents,
271- ... 'informational message'):
272- ... print tag.renderContents()
273- Celso Providelo (cprov) has been added as a member of this team.
274-
275
276 Adding teams
277 ------------
278@@ -217,36 +183,3 @@
279 ... 'informational message'):
280 ... print tag.renderContents()
281 This invitation has already been processed.
282-
283-
284-Evil workarounds
285-----------------
286-
287-One thing to keep in mind is that we can't invite a team without active
288-members.
289-XXX: This restriction was added as a workaround for
290-https://launchpad.net/bugs/94164, but I don't think it's the correct fix for
291-the bug sice we could skip the notification sent to the team in this case.
292--- Guilherme Salgado, 2007-05-09
293-
294- # Ideally we should do this using the web UI, but doing it this way is a
295- # lot simpler.
296- >>> carlos = Person.byName('carlos')
297- >>> ubuntu_translators = Person.byName('ubuntu-translators')
298- >>> login(ANONYMOUS) # login() because we need a zope interaction.
299- >>> carlos_translators_membership = TeamMembership.selectOneBy(
300- ... personID=carlos.id, teamID=ubuntu_translators.id)
301- >>> ignored = carlos_translators_membership.setStatus(
302- ... TeamMembershipStatus.DEACTIVATED, ubuntu_translators.teamowner)
303- >>> logout()
304- >>> carlos_translators_membership.syncUpdate()
305-
306- >>> browser = setupBrowser(auth='Basic test@canonical.com:test')
307- >>> browser.open('http://launchpad.dev/~landscape-developers/+addmember')
308- >>> browser.getControl('New member').value = 'ubuntu-translators'
309- >>> browser.getControl('Add Member').click()
310-
311- >>> for tag in find_tags_by_class(browser.contents, 'message'):
312- ... print tag.renderContents()
313- There is 1 error.
314- You can't add a team that doesn't have any active members.
315
316=== modified file 'lib/lp/registry/templates/person-editpgpkeys.pt'
317--- lib/lp/registry/templates/person-editpgpkeys.pt 2010-10-26 22:40:11 +0000
318+++ lib/lp/registry/templates/person-editpgpkeys.pt 2010-11-11 23:06:43 +0000
319@@ -107,8 +107,12 @@
320 </div>
321 <div><input type="submit" value="Deactivate Key" /></div>
322
323- <p><strong>Note:</strong> If you deactivate a key here, Launchpad will automatically disable any features that
324- use that key, such as a signed code of conduct. Also, the key will be deactivated on Launchpad only.</p>
325+ <p>
326+ <strong>Note:</strong> deactivating a key in Launchpad disables all
327+ Launchpad features that use that key such as signed codes of conduct.
328+ Deactivating the key in Launchpad does not alter the key outside of
329+ Launchpad.
330+ </p>
331
332 </form>
333
334
335=== modified file 'lib/lp/registry/templates/product-new.pt'
336--- lib/lp/registry/templates/product-new.pt 2010-08-09 04:45:18 +0000
337+++ lib/lp/registry/templates/product-new.pt 2010-11-11 23:06:43 +0000
338@@ -239,9 +239,10 @@
339 });
340 </script>
341
342- <div style="font-size: larger; background: #e0f0d0;
343+ <div id="staging-message" style="font-size: larger; background: #e0f0d0;
344 padding: 0.3em; -moz-border-radius: 5px; -o-border-radius: 5px;
345- -webkit-border-radius: 5px; margin-bottom: 1em;">
346+ -webkit-border-radius: 5px; margin-bottom: 1em;"
347+ tal:condition="not: is_demo">
348 You can <strong>test Launchpad's features</strong> at <a
349 href="https://staging.launchpad.net/">staging.launchpad.net</a>
350 <form style="display: inline; font-size: smaller"
351
352=== modified file 'lib/lp/registry/templates/product-portlet-packages.pt'
353--- lib/lp/registry/templates/product-portlet-packages.pt 2010-05-17 17:29:08 +0000
354+++ lib/lp/registry/templates/product-portlet-packages.pt 2010-11-11 23:06:43 +0000
355@@ -11,7 +11,7 @@
356 <span class="see-all"><a
357 tal:attributes="href context/menu:overview/packages/fmt:url">
358 All packages</a></span>
359- Packages in Ubuntu
360+ Packages in Distributions
361 </h2>
362
363 <tal:has_packages condition="packages">