~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/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:
15
15
import pytz
16
16
from zope.app.form import CustomWidgetFactory
17
17
from zope.app.form.interfaces import InputErrors
18
 
from zope.component import getUtility
19
18
from zope.formlib import form
20
19
from zope.schema import Date
21
20
 
22
21
from lp import _
23
22
from lp.app.errors import UnexpectedFormData
24
 
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
25
23
from lp.app.widgets.date import DateWidget
26
24
from lp.registry.interfaces.teammembership import TeamMembershipStatus
27
25
from lp.services.webapp import (
96
94
        return '%s member %s' % (prefix, self.context.person.displayname)
97
95
 
98
96
    # Boolean helpers
99
 
    def userIsTeamOwnerOrLPAdmin(self):
100
 
        return (self.user.inTeam(self.context.team.teamowner) or
101
 
                self.user.inTeam(getUtility(ILaunchpadCelebrities).admin))
102
 
 
103
 
    def allowChangeAdmin(self):
104
 
        return self.userIsTeamOwnerOrLPAdmin() or self.isAdmin()
105
 
 
106
97
    def isActive(self):
107
98
        return self.context.status in [TeamMembershipStatus.APPROVED,
108
99
                                       TeamMembershipStatus.ADMIN]
225
216
                context.status == TeamMembershipStatus.ADMIN):
226
217
                new_status = TeamMembershipStatus.APPROVED
227
218
            elif (form.get('admin') == "yes" and
228
 
                  context.status == TeamMembershipStatus.APPROVED
229
 
                  # XXX: salgado 2005-03-15: The clause below is a hack
230
 
                  # to make sure only the teamowner can promote a given
231
 
                  # member to admin, while we don't have a specific
232
 
                  # permission setup for this.
233
 
                  and self.userIsTeamOwnerOrLPAdmin()):
 
219
                  context.status == TeamMembershipStatus.APPROVED):
234
220
                new_status = TeamMembershipStatus.ADMIN
235
221
            else:
236
222
                # No status change will happen