~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/distributionsourcepackage.py

Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from canonical.launchpad.database.emailaddress import EmailAddress
39
39
from canonical.launchpad.interfaces.lpstorm import IStore
40
40
from canonical.lazr.utils import smartquote
41
 
from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
42
41
from lp.bugs.interfaces.bugtarget import IHasBugHeat
43
42
from lp.bugs.interfaces.bugtask import UNRESOLVED_BUGTASK_STATUSES
44
43
from lp.bugs.model.bug import (
45
44
    Bug,
46
45
    BugSet,
 
46
    get_bug_tags_open_count,
47
47
    )
48
48
from lp.bugs.model.bugtarget import (
49
49
    BugTargetBase,
139
139
    """
140
140
 
141
141
    implements(
142
 
        IBugSummaryDimension, IDistributionSourcePackage, IHasBugHeat,
143
 
        IHasCustomLanguageCodes)
 
142
        IDistributionSourcePackage, IHasBugHeat, IHasCustomLanguageCodes)
144
143
 
145
144
    bug_reporting_guidelines = DistributionSourcePackageProperty(
146
145
        'bug_reporting_guidelines')
473
472
        """See `IDistributionSourcePackage`."""
474
473
        return not self.__eq__(other)
475
474
 
476
 
    def getBugSummaryContextWhereClause(self):
 
475
    def _getBugTaskContextWhereClause(self):
477
476
        """See `BugTargetBase`."""
478
 
        # Circular fail.
479
 
        from lp.bugs.model.bugsummary import BugSummary
480
 
        return And(
481
 
            BugSummary.distribution == self.distribution,
482
 
            BugSummary.sourcepackagename == self.sourcepackagename),
 
477
        return (
 
478
            "BugTask.distribution = %d AND BugTask.sourcepackagename = %d" % (
 
479
            self.distribution.id, self.sourcepackagename.id))
483
480
 
484
481
    def _customizeSearchParams(self, search_params):
485
482
        """Customize `search_params` for this distribution source package."""
489
486
        """See `IBugTarget`."""
490
487
        return self.distribution.getUsedBugTags()
491
488
 
 
489
    def getUsedBugTagsWithOpenCounts(self, user, tag_limit=0, include_tags=None):
 
490
        """See IBugTarget."""
 
491
        # Circular fail.
 
492
        from lp.bugs.model.bugsummary import BugSummary
 
493
        return get_bug_tags_open_count(
 
494
            And(BugSummary.distribution == self.distribution,
 
495
                BugSummary.sourcepackagename == self.sourcepackagename),
 
496
            user, tag_limit=tag_limit, include_tags=include_tags)
 
497
 
492
498
    def _getOfficialTagClause(self):
493
499
        return self.distribution._getOfficialTagClause()
494
500
 
504
510
            sourcepackagename=self.sourcepackagename)
505
511
        return BugSet().createBug(bug_params)
506
512
 
 
513
    def _getBugTaskContextClause(self):
 
514
        """See `BugTargetBase`."""
 
515
        return (
 
516
            'BugTask.distribution = %s AND BugTask.sourcepackagename = %s' %
 
517
                sqlvalues(self.distribution, self.sourcepackagename))
 
518
 
507
519
    def composeCustomLanguageCodeMatch(self):
508
520
        """See `HasCustomLanguageCodesMixin`."""
509
521
        return And(