~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/person.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:
43
43
    'PersonRdfView',
44
44
    'PersonRelatedBugTaskSearchListingView',
45
45
    'PersonRelatedSoftwareView',
 
46
    'PersonRenameFormMixin',
46
47
    'PersonReportedBugTaskSearchListingView',
47
48
    'PersonSearchQuestionsView',
48
49
    'PersonSetActionNavigationMenu',
289
290
from lp.soyuz.browser.archivesubscription import (
290
291
    traverse_archive_subscription_for_subscriber,
291
292
    )
292
 
from lp.soyuz.enums import ArchiveStatus
293
 
from lp.soyuz.interfaces.archive import IArchiveSet
294
293
from lp.soyuz.interfaces.archivesubscriber import IArchiveSubscriberSet
295
294
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
296
295
from lp.soyuz.interfaces.publishing import ISourcePackagePublishingHistory
3431
3430
    page_title = label
3432
3431
 
3433
3432
 
3434
 
class PersonEditView(BasePersonEditView):
 
3433
class PersonRenameFormMixin(LaunchpadEditFormView):
 
3434
 
 
3435
    def setUpWidgets(self):
 
3436
        """See `LaunchpadViewForm`.
 
3437
 
 
3438
        Renames are prohibited if a person/team has an active PPA or an
 
3439
        active mailing list.
 
3440
        """
 
3441
        reason = self.context.checkRename()
 
3442
        if reason:
 
3443
            # This makes the field's widget display (i.e. read) only.
 
3444
            self.form_fields['name'].for_display = True
 
3445
        super(PersonRenameFormMixin, self).setUpWidgets()
 
3446
        if reason:
 
3447
            self.widgets['name'].hint = reason
 
3448
 
 
3449
 
 
3450
class PersonEditView(PersonRenameFormMixin, BasePersonEditView):
3435
3451
    """The Person 'Edit' page."""
3436
3452
 
3437
3453
    field_names = ['displayname', 'name', 'mugshot', 'homepage_content',
3448
3464
    # account with full knowledge of the consequences.
3449
3465
    i_know_this_is_an_openid_security_issue_input = None
3450
3466
 
3451
 
    def setUpWidgets(self):
3452
 
        """See `LaunchpadViewForm`.
3453
 
 
3454
 
        When a user has a PPA renames are prohibited.
3455
 
        """
3456
 
        has_ppa_with_published_packages = (
3457
 
            getUtility(IArchiveSet).getPPAOwnedByPerson(
3458
 
                self.context, has_packages=True,
3459
 
                statuses=[ArchiveStatus.ACTIVE,
3460
 
                          ArchiveStatus.DELETING]) is not None)
3461
 
        if has_ppa_with_published_packages:
3462
 
            # This makes the field's widget display (i.e. read) only.
3463
 
            self.form_fields['name'].for_display = True
3464
 
        super(PersonEditView, self).setUpWidgets()
3465
 
        if has_ppa_with_published_packages:
3466
 
            self.widgets['name'].hint = _(
3467
 
                'This user has an active PPA with packages published and '
3468
 
                'may not be renamed.')
3469
 
 
3470
3467
    def validate(self, data):
3471
3468
        """If the name changed, warn the user about the implications."""
3472
3469
        new_name = data.get('name')