~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/model/bugtask.py

[r=wgrant][ui=huwshimi][bug=878605] We don't want to support
 multi-tenanted private bugs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
387
387
    return validate_person(self, attr, value)
388
388
 
389
389
 
390
 
def validate_target(bug, target):
 
390
def validate_target(bug, target, retarget_existing=True):
391
391
    """Validate a bugtask target against a bug's existing tasks.
392
392
 
393
393
    Checks that no conflicting tasks already exist.
409
409
            except NotFoundError, e:
410
410
                raise IllegalTarget(e[0])
411
411
 
 
412
    if bug.private and not bool(features.getFeatureFlag(
 
413
            'disclosure.allow_multipillar_private_bugs.enabled')):
 
414
        # Perhaps we are replacing the one and only existing bugtask, in
 
415
        # which case that's ok.
 
416
        if retarget_existing and len(bug.bugtasks) <= 1:
 
417
            return
 
418
        # We can add a target so long as the pillar exists already.
 
419
        num_affected_pillars = len(bug.affected_pillars)
 
420
        if (len(bug.affected_pillars) > 0
 
421
                and target.pillar not in bug.affected_pillars):
 
422
            raise IllegalTarget(
 
423
                "This private bug already affects %s. "
 
424
                "Private bugs cannot affect multiple projects."
 
425
                    % bug.default_bugtask.target.bugtargetdisplayname)
 
426
 
412
427
 
413
428
def validate_new_target(bug, target):
414
429
    """Validate a bugtask target to be added.
444
459
                "specified. You should fill in a package name for "
445
460
                "the existing bug." % target.distribution.displayname)
446
461
 
447
 
    validate_target(bug, target)
 
462
    validate_target(bug, target, retarget_existing=False)
448
463
 
449
464
 
450
465
class BugTask(SQLBase):