~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/teammembership.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-03 22:43:32 UTC
  • mfrom: (14443.3.8 no-team-admin-restrictions)
  • Revision ID: launchpad@pqm.canonical.com-20120103224332-5zi4vcvry7vg9l8h
[r=sinzui][bug=102180,
        206058] Let team admins promote others to admins and change their own
        expiration dates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from lp.registry.interfaces.persontransferjob import (
41
41
    IMembershipNotificationJobSource,
42
42
    )
 
43
from lp.registry.interfaces.role import IPersonRoles
43
44
from lp.registry.interfaces.teammembership import (
44
45
    ACTIVE_STATES,
45
46
    CyclicalTeamMembershipError,
199
200
 
200
201
    def canChangeExpirationDate(self, person):
201
202
        """See `ITeamMembership`."""
202
 
        person_is_admin = self.team in person.getAdministratedTeams()
203
 
        if (person.inTeam(self.team.teamowner) or
204
 
                person.inTeam(getUtility(ILaunchpadCelebrities).admin)):
205
 
            # The team owner and Launchpad admins can change the expiration
206
 
            # date of anybody's membership.
207
 
            return True
208
 
        elif person_is_admin and person != self.person:
209
 
            # A team admin can only change other member's expiration date.
210
 
            return True
211
 
        else:
212
 
            return False
 
203
        person_is_team_admin = self.team in person.getAdministratedTeams()
 
204
        person_is_lp_admin = IPersonRoles(person).in_admin
 
205
        return person_is_team_admin or person_is_lp_admin
213
206
 
214
207
    def setExpirationDate(self, date, user):
215
208
        """See `ITeamMembership`."""
273
266
                    % (admin.unique_displayname, canonical_url(admin)))
274
267
            else:
275
268
                for admin in admins:
276
 
                    # Do not tell the member to contact himself when he can't
277
 
                    # extend his membership.
278
 
                    if admin != member:
279
 
                        admins_names.append(
280
 
                            "%s <%s>" % (admin.unique_displayname,
281
 
                                         canonical_url(admin)))
 
269
                    admins_names.append(
 
270
                        "%s <%s>" % (admin.unique_displayname,
 
271
                                        canonical_url(admin)))
282
272
 
283
273
                how_to_renew = (
284
274
                    "To prevent this membership from expiring, you should "