Exemplo n.º 1
0
 def _create_bug_task(self, bug, bug_target):
     """Creates a new bug task with bug_target as the target."""
     user = getUtility(ILaunchBag).user
     if ISeriesBugTarget.providedBy(bug_target):
         return self._targetBug(user, bug, bug_target)
     else:
         return bug.addTask(user, bug_target)
Exemplo n.º 2
0
 def _create_bug_task(self, bug, bug_target):
     """Creates a new bug task with bug_target as the target."""
     user = getUtility(ILaunchBag).user
     if ISeriesBugTarget.providedBy(bug_target):
         return self._targetBug(user, bug, bug_target)
     else:
         return bug.addTask(user, bug_target)
Exemplo n.º 3
0
 def test_bugtarget_parent(self):
     self.assertTrue(ISeriesBugTarget.providedBy(self.bugtarget))
     self.assertEqual(
         self.bugtarget.distribution, self.bugtarget.bugtarget_parent)
Exemplo n.º 4
0
    def execute(self, bug, bug_event):
        """See IEmailCommand."""
        if bug is None:
            raise EmailProcessingError(get_error_message(
                'command-with-no-bug.txt', error_templates=error_templates),
                                       stop_processing=True)

        string_args = list(self.string_args)
        try:
            path = string_args.pop(0)
        except IndexError:
            raise EmailProcessingError(get_error_message(
                'affects-no-arguments.txt', error_templates=error_templates),
                                       stop_processing=True)
        try:
            bug_target = self.getBugTarget(path)
        except BugTargetNotFound as error:
            raise EmailProcessingError(unicode(error), stop_processing=True)
        event = None

        if isinstance(bug, CreateBugParams):
            # Enough information has been gathered to create a new bug.
            # If a series task is requested, create the non-series
            # equivalent here. The series will be nominated/targeted in
            # the remainder of the method.
            if ISeriesBugTarget.providedBy(bug_target):
                bug.target = bug_target.bugtarget_parent
            else:
                bug.target = bug_target
            bug, bug_event = getUtility(IBugSet).createBug(bug,
                                                           notify_event=False)
            event = ObjectCreatedEvent(bug.bugtasks[0])
            # Continue because the bug_target may be a subordinate bugtask.

        bugtask = bug.getBugTask(bug_target)
        if (bugtask is None
                and IDistributionSourcePackage.providedBy(bug_target)):
            # If there's a distribution task with no source package, use
            # that one.
            bugtask = bug.getBugTask(bug_target.distribution)
            if bugtask is not None:
                bugtask_before_edit = Snapshot(bugtask, providing=IBugTask)
                bugtask.transitionToTarget(bug_target,
                                           getUtility(ILaunchBag).user)
                event = ObjectModifiedEvent(bugtask, bugtask_before_edit,
                                            ['sourcepackagename'])

        if bugtask is None:
            try:
                bugtask = self._create_bug_task(bug, bug_target)
            except IllegalTarget as e:
                raise EmailProcessingError(get_error_message(
                    'cannot-add-task.txt',
                    error_templates=error_templates,
                    bug_id=bug.id,
                    target_name=bug_target.name,
                    reason=e[0]),
                                           stop_processing=True)
            event = ObjectCreatedEvent(bugtask)

        return bugtask, event, bug_event
Exemplo n.º 5
0
    def execute(self, bug, bug_event):
        """See IEmailCommand."""
        if bug is None:
            raise EmailProcessingError(
                get_error_message(
                    'command-with-no-bug.txt',
                    error_templates=error_templates),
                stop_processing=True)

        string_args = list(self.string_args)
        try:
            path = string_args.pop(0)
        except IndexError:
            raise EmailProcessingError(
                get_error_message(
                    'affects-no-arguments.txt',
                    error_templates=error_templates),
                stop_processing=True)
        try:
            bug_target = self.getBugTarget(path)
        except BugTargetNotFound as error:
            raise EmailProcessingError(unicode(error), stop_processing=True)
        event = None

        if isinstance(bug, CreateBugParams):
            # Enough information has been gathered to create a new bug.
            # If a series task is requested, create the non-series
            # equivalent here. The series will be nominated/targeted in
            # the remainder of the method.
            if ISeriesBugTarget.providedBy(bug_target):
                bug.target = bug_target.bugtarget_parent
            else:
                bug.target = bug_target
            bug, bug_event = getUtility(IBugSet).createBug(
                bug, notify_event=False)
            event = ObjectCreatedEvent(bug.bugtasks[0])
            # Continue because the bug_target may be a subordinate bugtask.

        bugtask = bug.getBugTask(bug_target)
        if (bugtask is None and
            IDistributionSourcePackage.providedBy(bug_target)):
            # If there's a distribution task with no source package, use
            # that one.
            bugtask = bug.getBugTask(bug_target.distribution)
            if bugtask is not None:
                bugtask_before_edit = Snapshot(
                    bugtask, providing=IBugTask)
                bugtask.transitionToTarget(
                    bug_target, getUtility(ILaunchBag).user)
                event = ObjectModifiedEvent(
                    bugtask, bugtask_before_edit, ['sourcepackagename'])

        if bugtask is None:
            try:
                bugtask = self._create_bug_task(bug, bug_target)
            except IllegalTarget as e:
                raise EmailProcessingError(
                    get_error_message(
                        'cannot-add-task.txt',
                        error_templates=error_templates,
                        bug_id=bug.id,
                        target_name=bug_target.name, reason=e[0]),
                    stop_processing=True)
            event = ObjectCreatedEvent(bugtask)

        return bugtask, event, bug_event
Exemplo n.º 6
0
 def test_bugtarget_parent(self):
     self.assertTrue(ISeriesBugTarget.providedBy(self.bugtarget))
     self.assertEqual(self.bugtarget.distribution,
                      self.bugtarget.bugtarget_parent)