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
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py 2010-06-28 21:56:49 +0000
+++ lib/lp/registry/browser/person.py 2010-06-30 01:41:29 +0000
@@ -557,9 +557,7 @@
557 def next_url(self):557 def next_url(self):
558 return canonical_url(self.context.person)558 return canonical_url(self.context.person)
559559
560 @property560 cancel_url = next_url
561 def cancel_url(self):
562 return canonical_url(self.context)
563561
564 @action(_("Renew"), name="renew")562 @action(_("Renew"), name="renew")
565 def renew_action(self, action, data):563 def renew_action(self, action, data):
@@ -4202,8 +4200,16 @@
4202 """Make the selected teams join this team."""4200 """Make the selected teams join this team."""
4203 context = self.context4201 context = self.context
4204 is_admin = check_permission('launchpad.Admin', context)4202 is_admin = check_permission('launchpad.Admin', context)
4203 membership_set = getUtility(ITeamMembershipSet)
4205 for team in data['teams']:4204 for team in data['teams']:
4206 if is_admin:4205 membership = membership_set.getByPersonAndTeam(team, context)
4206 if (membership is not None
4207 and membership.status == TeamMembershipStatus.INVITED):
4208 team.acceptInvitationToBeMemberOf(
4209 context,
4210 'Accepted an already pending invitation while trying to '
4211 'propose the team for membership.')
4212 elif is_admin:
4207 context.addMember(team, reviewer=self.user)4213 context.addMember(team, reviewer=self.user)
4208 else:4214 else:
4209 team.join(context, requester=self.user)4215 team.join(context, requester=self.user)
42104216
=== modified file 'lib/lp/registry/stories/team/xx-team-add-my-teams.txt'
--- lib/lp/registry/stories/team/xx-team-add-my-teams.txt 2009-12-24 01:38:11 +0000
+++ lib/lp/registry/stories/team/xx-team-add-my-teams.txt 2010-06-30 01:41:29 +0000
@@ -40,6 +40,34 @@
40 Pending approval40 Pending approval
41 Ubuntu Team...41 Ubuntu Team...
4242
43If the team is already invited, the invitation will be accepted instead
44of trying to propose the membership, which is an invalid status change.
45
46 >>> from zope.component import getUtility
47 >>> from lp.registry.interfaces.person import IPersonSet
48 >>> from storm.store import Store
49 >>> login('no-priv@canonical.com')
50 >>> inviting_owner = factory.makePerson(email="inviter@example.com")
51 >>> login('inviter@example.com')
52 >>> no_priv = getUtility(IPersonSet).getByName('no-priv')
53 >>> super_team = factory.makeTeam(name="super-team", owner=inviting_owner)
54 >>> sub_team = factory.makeTeam(name="sub-team", owner=no_priv)
55 >>> print super_team.addMember(sub_team, inviting_owner)
56 (True, <DBItem TeamMembershipStatus.INVITED...)
57 >>> Store.of(sub_team).flush()
58 >>> logout()
59 >>> user_browser.open('http://launchpad.dev/~super-team/+add-my-teams')
60 >>> user_browser.getControl(name='field.teams').value = ['sub-team']
61 >>> user_browser.getControl('Continue').click()
62 >>> print user_browser.title
63 Super Team in Launchpad
64 >>> print get_feedback_messages(user_browser.contents)
65 [u'Sub Team has been added to this team.']
66 >>> print extract_text(
67 ... find_tag_by_id(user_browser.contents, 'recently-approved'))
68 Latest members
69 Sub Team
70
43If it were an OPEN team, we'd be able to directly add any of our teams as71If it were an OPEN team, we'd be able to directly add any of our teams as
44members.72members.
4573