46
46
from canonical.launchpad.mailnotification import MailWrapper
47
47
from canonical.launchpad.webapp import canonical_url
48
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
48
49
from lp.registry.enum import PersonTransferJobType
49
50
from lp.registry.interfaces.person import (
345
346
class_job_type = PersonTransferJobType.MERGE
348
def create(cls, from_person, to_person, reviewer=None):
349
def create(cls, from_person, to_person, reviewer=None, delete=False):
349
350
"""See `IPersonMergeJobSource`."""
350
if from_person.is_merge_pending or to_person.is_merge_pending:
351
if (from_person.is_merge_pending or
352
(not delete and to_person.is_merge_pending)):
352
354
if from_person.is_team:
353
355
metadata = {'reviewer': reviewer.id}
358
metadata['delete'] = bool(delete)
359
if metadata['delete']:
360
# Ideally not needed, but the DB column is not-null at the moment
361
# and this minor bit of friction isn't worth changing that over.
362
to_person = getUtility(ILaunchpadCelebrities).registry_experts
356
363
return super(PersonMergeJob, cls).create(
357
364
minor_person=from_person, major_person=to_person,
358
365
metadata=metadata)
412
419
to_person_name = self.to_person.name
414
421
from canonical.launchpad.scripts import log
416
"%s is about to merge ~%s into ~%s", self.log_name,
417
from_person_name, to_person_name)
418
getUtility(IPersonSet).merge(
419
from_person=self.from_person, to_person=self.to_person,
420
reviewer=self.reviewer)
423
"%s has merged ~%s into ~%s", self.log_name,
424
from_person_name, to_person_name)
422
personset = getUtility(IPersonSet)
423
if self.metadata['delete']:
425
"%s is about to delete ~%s", self.log_name,
428
from_person=self.from_person,
429
reviewer=self.reviewer)
431
"%s has deleted ~%s", self.log_name,
435
"%s is about to merge ~%s into ~%s", self.log_name,
436
from_person_name, to_person_name)
438
from_person=self.from_person, to_person=self.to_person,
439
reviewer=self.reviewer)
441
"%s has merged ~%s into ~%s", self.log_name,
442
from_person_name, to_person_name)
426
444
def __repr__(self):