~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2012-01-03 07:30:21 UTC
  • mto: This revision was merged to the branch mainline in revision 14621.
  • Revision ID: william.grant@canonical.com-20120103073021-qvprj6kbnpg0h1qv
Update a few templates.

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
44
43
from lp.registry.interfaces.teammembership import (
45
44
    ACTIVE_STATES,
46
45
    CyclicalTeamMembershipError,
200
199
 
201
200
    def canChangeExpirationDate(self, person):
202
201
        """See `ITeamMembership`."""
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
 
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
206
213
 
207
214
    def setExpirationDate(self, date, user):
208
215
        """See `ITeamMembership`."""
266
273
                    % (admin.unique_displayname, canonical_url(admin)))
267
274
            else:
268
275
                for admin in admins:
269
 
                    admins_names.append(
270
 
                        "%s <%s>" % (admin.unique_displayname,
271
 
                                        canonical_url(admin)))
 
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)))
272
282
 
273
283
                how_to_renew = (
274
284
                    "To prevent this membership from expiring, you should "