Merge lp:~sinzui/launchpad/retract-membership-0 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Merged at revision: 11962
Proposed branch: lp:~sinzui/launchpad/retract-membership-0
Merge into: lp:launchpad
Diff against target: 59 lines (+21/-3)
2 files modified
lib/lp/registry/interfaces/person.py (+9/-3)
lib/lp/registry/stories/webservice/xx-person.txt (+12/-0)
To merge this branch: bzr merge lp:~sinzui/launchpad/retract-membership-0
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) code Approve
Review via email: mp+41511@code.launchpad.net

Description of the change

This is my branch to allow team admins to remove their team from another team
via an API call.

    lp:~sinzui/launchpad/retract-membership-0
    Diff size: 47
    Launchpad bug: https://bugs.launchpad.net/bugs/680152
    Test command: ./bin/test -vv -t webservice/xx-person.txt
    Pre-implementation: abentley, leonardr
    Target release: 10.12

Allow team admins to remove their team from another team via an API call
------------------------------------------------------------------------

Team admins can accept or decline the invitation to join a team, but
they cannot retract an accepted invitation. The only way a team can
leave another team is by the the admin of the subteam requesting an admin
of the superteam to do the removal. Team admins, like users, should have
the power to retract their memberships.

Rules
-----

    * Export retractTeamMembership over the API.

QA
--

# This script tests that a team admin can remove his team from it's
# super teams.
from launchpadlib.launchpad import Launchpad STAGING_SERVICE_ROOT

def retract_registry_memberships():
    lp = Launchpad.login_with('testing', STAGING_SERVICE_ROOT)
    my_team = lp.people['registry']
    for super_team in my_team.teams_participated_in:
        print "Removing %s from %s" % (my_team.name, super_team.name)
        try:
            my_team.retractTeamMembership(team=super_team)
        except:
            pass

if __name__ == '__main__':
    retract_registry_memberships()

Lint
----

Linting changed files:
  lib/lp/registry/interfaces/person.py
  lib/lp/registry/stories/webservice/xx-person.txt

There are indentation and header issues in the test that I can fix after the
review.

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Curtis,

This branch looks good. I just have one comment below.

-Edwin

>=== modified file 'lib/lp/registry/interfaces/person.py'
>--- lib/lp/registry/interfaces/person.py 2010-11-18 12:05:34 +0000
>+++ lib/lp/registry/interfaces/person.py 2010-11-22 22:14:01 +0000
>@@ -1075,10 +1075,10 @@
> since it inherits from `IPerson`) is a member of himself
> (i.e. `person1.inTeam(person1)`).
>
>- :param team: One of an object providing `IPerson`, the string name of a
>- team or `None`. If a string was supplied the team is looked up.
>+ :param team: One of an object providing `IPerson`, the string name of
>+ a team or `None`. If a string was supplied the team is looked up.

I think "One of" should be rewritten either as "One of the following:"
or just "Either".

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py 2010-11-18 12:05:34 +0000
+++ lib/lp/registry/interfaces/person.py 2010-11-22 23:11:44 +0000
@@ -1075,10 +1075,10 @@
1075 since it inherits from `IPerson`) is a member of himself1075 since it inherits from `IPerson`) is a member of himself
1076 (i.e. `person1.inTeam(person1)`).1076 (i.e. `person1.inTeam(person1)`).
10771077
1078 :param team: One of an object providing `IPerson`, the string name of a1078 :param team: Either an object providing `IPerson`, the string name of
1079 team or `None`. If a string was supplied the team is looked up.1079 a team or `None`. If a string was supplied the team is looked up.
1080 :return: A bool with the result of the membership lookup. When looking1080 :return: A bool with the result of the membership lookup. When looking
1081 up the team from a string finds nothing or team was `None` then 1081 up the team from a string finds nothing or team was `None` then
1082 `False` is returned.1082 `False` is returned.
1083 """1083 """
10841084
@@ -1551,6 +1551,11 @@
1551 to INVITATION_DECLINED.1551 to INVITATION_DECLINED.
1552 """1552 """
15531553
1554 @call_with(user=REQUEST_USER)
1555 @operation_parameters(
1556 team=copy_field(ITeamMembership['team']),
1557 comment=Text(required=False))
1558 @export_write_operation()
1554 def retractTeamMembership(team, user, comment=None):1559 def retractTeamMembership(team, user, comment=None):
1555 """Retract this team's membership in the given team.1560 """Retract this team's membership in the given team.
15561561
@@ -2238,6 +2243,7 @@
2238 (IPersonEditRestricted['addMember'], 'person'),2243 (IPersonEditRestricted['addMember'], 'person'),
2239 (IPersonEditRestricted['acceptInvitationToBeMemberOf'], 'team'),2244 (IPersonEditRestricted['acceptInvitationToBeMemberOf'], 'team'),
2240 (IPersonEditRestricted['declineInvitationToBeMemberOf'], 'team'),2245 (IPersonEditRestricted['declineInvitationToBeMemberOf'], 'team'),
2246 (IPersonEditRestricted['retractTeamMembership'], 'team'),
2241 ]2247 ]
2242for method, name in params_to_fix:2248for method, name in params_to_fix:
2243 method.queryTaggedValue(2249 method.queryTaggedValue(
22442250
=== modified file 'lib/lp/registry/stories/webservice/xx-person.txt'
--- lib/lp/registry/stories/webservice/xx-person.txt 2010-10-18 22:24:59 +0000
+++ lib/lp/registry/stories/webservice/xx-person.txt 2010-11-22 23:11:44 +0000
@@ -749,6 +749,18 @@
749 >>> webservice.get("/~ubuntu-team/+member/name20").jsonBody()['status']749 >>> webservice.get("/~ubuntu-team/+member/name20").jsonBody()['status']
750 u'Invitation declined'750 u'Invitation declined'
751751
752The retractTeamMembership method allows a team admin to remove his team from
753another team.
754
755 >>> print webservice.named_post(
756 ... landscape_developers['self_link'], 'retractTeamMembership',
757 ... {}, team=ubuntu_team['self_link'], comment='bye bye')
758 HTTP/1.1 200 Ok
759 ...
760 >>> webservice.get("/~ubuntu-team/+member/landscape-developers"
761 ... ).jsonBody()['status']
762 u'Deactivated'
763
752To check whether or not a given person is a participant in a team, use the764To check whether or not a given person is a participant in a team, use the
753'inTeam' custom operation.765'inTeam' custom operation.
754766