Merge lp:~edwin-grubbs/launchpad/bug-576388-proposing-invited-team into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: 11080
Proposed branch: lp:~edwin-grubbs/launchpad/bug-576388-proposing-invited-team
Merge into: lp:launchpad
Diff against target: 70 lines (+38/-4)
2 files modified
lib/lp/registry/browser/person.py (+10/-4)
lib/lp/registry/stories/team/xx-team-add-my-teams.txt (+28/-0)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-576388-proposing-invited-team
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+28786@code.launchpad.net

Description of the change

Summary
-------

This branch fixes bug 517439 and bug 576388.

For bug 517439, the "Renew" button appears to have been fixed already, but
the "Cancel" link still had the problem where it would redirect the user
to the membership index page, which is only viewable by team admins.

For bug 576388, when the user submits the form, it checks whether he
is trying to propose a team that is already invited. If that is the
case, the invitation is accepted.

Tests
-----

./bin/test -vv -t xx-team-add-my-teams.txt

Demo and Q/A
------------

Test accepting an invitation on the +add-my-teams page:
* Create team "foo" owned by foo-owner.
* Create team "bar" owned by bar-owner.
* User foo-owner should add bar as a member. It will show up in the
  "Latest invited" list on foo's index page.
* User bar-owner should go to foo's index page and click on
  the "Add one of my teams" link, then select the "bar" radio
  button, and click the "Continue" button.
* The foo index page should now show bar in the "Latest members"
  list and not the "Pending approval" list.

Test "Cancel" button on +expiringmembership page:

* Create a team that allows members to renew their own membership.
* Add a member.
* You will need the membership to expire within 7 days. This can be
  done by clicking on the "All members" link and then clicking on the
  edit link next to the member you want to renew.
* Open http://launchpad.dev/~USERNAME/+expiringmembership/TEAMNAME
  * Click "Cancel".
  * You should be taken to the /~USERNAME overview page.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

1. 'Accepted invitation whilst trying to propose the team' is awkward. Rephrase to something like "Accepted an already pending invitation while trying to propose the team for membership."

2. The "Accepted an already pending invitation" string isn't tested. Would it be difficult to show where that string is used (I'm guessing in an email)? If it's very difficult to test, I think it's not a big deal.

r=me with those changes.

review: Approve
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

I made change #1. The comment isn't actually viewable anywhere, so I didn't add a test for it, but maybe it will be helpful when somebody is debugging a team membership problem.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/person.py'
2--- lib/lp/registry/browser/person.py 2010-06-28 21:56:49 +0000
3+++ lib/lp/registry/browser/person.py 2010-06-30 01:41:29 +0000
4@@ -557,9 +557,7 @@
5 def next_url(self):
6 return canonical_url(self.context.person)
7
8- @property
9- def cancel_url(self):
10- return canonical_url(self.context)
11+ cancel_url = next_url
12
13 @action(_("Renew"), name="renew")
14 def renew_action(self, action, data):
15@@ -4202,8 +4200,16 @@
16 """Make the selected teams join this team."""
17 context = self.context
18 is_admin = check_permission('launchpad.Admin', context)
19+ membership_set = getUtility(ITeamMembershipSet)
20 for team in data['teams']:
21- if is_admin:
22+ membership = membership_set.getByPersonAndTeam(team, context)
23+ if (membership is not None
24+ and membership.status == TeamMembershipStatus.INVITED):
25+ team.acceptInvitationToBeMemberOf(
26+ context,
27+ 'Accepted an already pending invitation while trying to '
28+ 'propose the team for membership.')
29+ elif is_admin:
30 context.addMember(team, reviewer=self.user)
31 else:
32 team.join(context, requester=self.user)
33
34=== modified file 'lib/lp/registry/stories/team/xx-team-add-my-teams.txt'
35--- lib/lp/registry/stories/team/xx-team-add-my-teams.txt 2009-12-24 01:38:11 +0000
36+++ lib/lp/registry/stories/team/xx-team-add-my-teams.txt 2010-06-30 01:41:29 +0000
37@@ -40,6 +40,34 @@
38 Pending approval
39 Ubuntu Team...
40
41+If the team is already invited, the invitation will be accepted instead
42+of trying to propose the membership, which is an invalid status change.
43+
44+ >>> from zope.component import getUtility
45+ >>> from lp.registry.interfaces.person import IPersonSet
46+ >>> from storm.store import Store
47+ >>> login('no-priv@canonical.com')
48+ >>> inviting_owner = factory.makePerson(email="inviter@example.com")
49+ >>> login('inviter@example.com')
50+ >>> no_priv = getUtility(IPersonSet).getByName('no-priv')
51+ >>> super_team = factory.makeTeam(name="super-team", owner=inviting_owner)
52+ >>> sub_team = factory.makeTeam(name="sub-team", owner=no_priv)
53+ >>> print super_team.addMember(sub_team, inviting_owner)
54+ (True, <DBItem TeamMembershipStatus.INVITED...)
55+ >>> Store.of(sub_team).flush()
56+ >>> logout()
57+ >>> user_browser.open('http://launchpad.dev/~super-team/+add-my-teams')
58+ >>> user_browser.getControl(name='field.teams').value = ['sub-team']
59+ >>> user_browser.getControl('Continue').click()
60+ >>> print user_browser.title
61+ Super Team in Launchpad
62+ >>> print get_feedback_messages(user_browser.contents)
63+ [u'Sub Team has been added to this team.']
64+ >>> print extract_text(
65+ ... find_tag_by_id(user_browser.contents, 'recently-approved'))
66+ Latest members
67+ Sub Team
68+
69 If it were an OPEN team, we'd be able to directly add any of our teams as
70 members.
71