Пример #1
0
 def validate_existing_product(self, action, data):
     """Check if the chosen project is not already affected by this bug."""
     self._validate(action, data)
     project = data.get('existing_product')
     try:
         validate_target(self.context.bug, project)
     except IllegalTarget as e:
         self.setFieldError('existing_product', e[0])
Пример #2
0
    def maybeAddNotificationOrTeleport(self):
        """If we can't infer the upstream and the target distribution has a
        currentseries we add a notification message telling the user the
        package could be linked to an upstream to avoid this extra step.

        On the other hand, if the upstream can be infered and there's no task
        for it yet, we teleport the user straight to the next step.
        """
        bugtask = self.context
        upstream = bugtask.target.upstream_product
        if upstream is not None:
            try:
                validate_target(bugtask.bug, upstream)
            except IllegalTarget:
                # There is already a task for the upstream.
                pass
            else:
                # We can infer the upstream and there's no bugtask for it,
                # so we can go straight to the page asking for the remote
                # bug URL.
                self.request.form['field.product'] = upstream.name
                self.request.form['field.add_packaging'] = 'off'
                self.next_step = ProductBugTaskCreationStep
            return