~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-02 04:21:43 UTC
  • mfrom: (13571.2.4 createtask-and-addtask)
  • Revision ID: launchpad@pqm.canonical.com-20110802042143-26jeqxhukor1eg0e
[r=benji][no-qa] Bug.addTask and BugTaskSet.createTask now take an
 IBugTarget directly instead of a target key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
from canonical.launchpad.webapp.authorization import check_permission
107
107
from canonical.launchpad.webapp.interfaces import (
108
108
    DEFAULT_FLAVOR,
109
 
    ILaunchBag,
110
109
    IStoreSelector,
111
110
    MAIN_STORE,
112
111
    )
177
176
from lp.code.interfaces.branchcollection import IAllBranches
178
177
from lp.hardwaredb.interfaces.hwdb import IHWSubmissionBugSet
179
178
from lp.registry.interfaces.distribution import IDistribution
180
 
from lp.registry.interfaces.distributionsourcepackage import (
181
 
    IDistributionSourcePackage,
182
 
    )
183
179
from lp.registry.interfaces.distroseries import IDistroSeries
184
180
from lp.registry.interfaces.person import (
185
181
    IPersonSet,
1183
1179
 
1184
1180
    def addTask(self, owner, target):
1185
1181
        """See `IBug`."""
1186
 
        product = None
1187
 
        product_series = None
1188
 
        distribution = None
1189
 
        distro_series = None
1190
 
        source_package_name = None
1191
 
 
1192
 
        # Turn `target` into something more useful.
1193
 
        if IProduct.providedBy(target):
1194
 
            product = target
1195
 
        if IProductSeries.providedBy(target):
1196
 
            product_series = target
1197
 
        if IDistribution.providedBy(target):
1198
 
            distribution = target
1199
 
        if IDistroSeries.providedBy(target):
1200
 
            distro_series = target
1201
 
        if IDistributionSourcePackage.providedBy(target):
1202
 
            distribution = target.distribution
1203
 
            source_package_name = target.sourcepackagename
1204
 
        if ISourcePackage.providedBy(target):
1205
 
            distro_series = target.distroseries
1206
 
            source_package_name = target.sourcepackagename
1207
 
 
1208
 
        new_task = getUtility(IBugTaskSet).createTask(
1209
 
            self, owner=owner, product=product,
1210
 
            productseries=product_series, distribution=distribution,
1211
 
            distroseries=distro_series,
1212
 
            sourcepackagename=source_package_name)
 
1182
        new_task = getUtility(IBugTaskSet).createTask(self, owner, target)
1213
1183
 
1214
1184
        # When a new task is added the bug's heat becomes relevant to the
1215
1185
        # target's max_bug_heat.
2531
2501
        # Create the task on a product if one was passed.
2532
2502
        if params.product:
2533
2503
            getUtility(IBugTaskSet).createTask(
2534
 
                bug=bug, product=params.product, owner=params.owner,
2535
 
                status=params.status)
 
2504
                bug, params.owner, params.product, status=params.status)
2536
2505
 
2537
2506
        # Create the task on a source package name if one was passed.
2538
2507
        if params.distribution:
 
2508
            target = params.distribution
 
2509
            if params.sourcepackagename:
 
2510
                target = target.getSourcePackage(params.sourcepackagename)
2539
2511
            getUtility(IBugTaskSet).createTask(
2540
 
                bug=bug, distribution=params.distribution,
2541
 
                sourcepackagename=params.sourcepackagename,
2542
 
                owner=params.owner, status=params.status)
 
2512
                bug, params.owner, target, status=params.status)
2543
2513
 
2544
2514
        bug_task = bug.default_bugtask
2545
2515
        if params.assignee: