~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/team.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 14116,
        14117, 14118, 14119, 14120 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
from lp.app.browser.launchpadform import (
99
99
    action,
100
100
    custom_widget,
101
 
    LaunchpadEditFormView,
102
101
    LaunchpadFormView,
103
102
    )
104
103
from lp.app.browser.tales import PersonFormatterAPI
119
118
    CommonMenuLinks,
120
119
    PersonIndexView,
121
120
    PersonNavigation,
 
121
    PersonRenameFormMixin,
122
122
    PPANavigationMenuMixIn,
123
123
    )
124
124
from lp.registry.browser.teamjoin import (
260
260
            self.form_fields = self.form_fields.omit('visibility')
261
261
 
262
262
 
263
 
class TeamEditView(TeamFormMixin, HasRenewalPolicyMixin,
264
 
                   LaunchpadEditFormView):
 
263
class TeamEditView(TeamFormMixin, PersonRenameFormMixin,
 
264
                   HasRenewalPolicyMixin):
265
265
    """View for editing team details."""
266
266
    schema = ITeam
267
267
 
311
311
 
312
312
    cancel_url = next_url
313
313
 
314
 
    def setUpWidgets(self):
315
 
        """See `LaunchpadViewForm`.
316
 
 
317
 
        When a team has a mailing list, a PPA or is private, renames
318
 
        are prohibited.
319
 
        """
320
 
        mailing_list = getUtility(IMailingListSet).get(self.context.name)
321
 
        has_mailing_list = (
322
 
            mailing_list is not None and
323
 
            mailing_list.status != MailingListStatus.PURGED)
324
 
        has_ppa = self.context.archive is not None
325
 
 
326
 
        block_renaming = (has_mailing_list or has_ppa)
327
 
        if block_renaming:
328
 
            # This makes the field's widget display (i.e. read) only.
329
 
            self.form_fields['name'].for_display = True
330
 
 
331
 
        super(TeamEditView, self).setUpWidgets()
332
 
 
333
 
        # Tweak the field form-help including an explanation for the
334
 
        # read-only mode if necessary.
335
 
        if block_renaming:
336
 
            # Group the read-only mode reasons in textual form.
337
 
            reasons = []
338
 
            if has_mailing_list:
339
 
                reasons.append('has a mailing list')
340
 
            if has_ppa:
341
 
                reasons.append('has a PPA')
342
 
            reason = ' and '.join(reasons)
343
 
            self.widgets['name'].hint = _(
344
 
                'This team cannot be renamed because it %s.' % reason)
345
 
 
346
314
 
347
315
def generateTokenAndValidationEmail(email, team):
348
316
    """Send a validation message to the given email."""