~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/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:
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
18
19
from zope.formlib import form
19
20
from zope.schema import Date
20
21
 
21
22
from lp import _
22
23
from lp.app.errors import UnexpectedFormData
 
24
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
23
25
from lp.app.widgets.date import DateWidget
24
26
from lp.registry.interfaces.teammembership import TeamMembershipStatus
25
27
from lp.services.webapp import (
94
96
        return '%s member %s' % (prefix, self.context.person.displayname)
95
97
 
96
98
    # 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
 
97
106
    def isActive(self):
98
107
        return self.context.status in [TeamMembershipStatus.APPROVED,
99
108
                                       TeamMembershipStatus.ADMIN]
216
225
                context.status == TeamMembershipStatus.ADMIN):
217
226
                new_status = TeamMembershipStatus.APPROVED
218
227
            elif (form.get('admin') == "yes" and
219
 
                  context.status == TeamMembershipStatus.APPROVED):
 
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()):
220
234
                new_status = TeamMembershipStatus.ADMIN
221
235
            else:
222
236
                # No status change will happen