30
30
'CommercialProjectsVocabulary',
31
31
'DistributionOrProductOrProjectGroupVocabulary',
32
32
'DistributionOrProductVocabulary',
33
'DistributionSourcePackageVocabulary',
33
34
'DistributionVocabulary',
34
35
'DistroSeriesDerivationVocabulary',
35
36
'DistroSeriesVocabulary',
167
168
from lp.registry.interfaces.projectgroup import IProjectGroup
168
169
from lp.registry.interfaces.sourcepackage import ISourcePackage
169
170
from lp.registry.model.distribution import Distribution
171
from lp.registry.model.distributionsourcepackage import (
172
DistributionSourcePackage,
170
174
from lp.registry.model.distroseries import DistroSeries
171
175
from lp.registry.model.distroseriesparent import DistroSeriesParent
172
176
from lp.registry.model.featuredproject import FeaturedProject
191
195
get_property_cache,
197
from lp.soyuz.enums import PackagePublishingStatus
198
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
199
from lp.soyuz.model.binarypackagename import BinaryPackageName
200
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
193
201
from lp.soyuz.model.distroarchseries import DistroArchSeries
202
from lp.soyuz.model.publishing import (
203
BinaryPackagePublishingHistory,
204
SourcePackagePublishingHistory,
206
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
196
209
class BasePersonVocabulary:
1949
1962
# package names are always lowercase.
1950
1963
return super(SourcePackageNameVocabulary, self).getTermByToken(
1967
class DistributionSourcePackageVocabulary:
1969
implements(IHugeVocabulary)
1970
displayname = 'Select a package'
1971
step_title = 'Search'
1973
def __init__(self, context=None):
1974
self.context = context
1976
def __contains__(self, obj):
1985
def toTerm(self, dsp):
1986
"""See `IVocabulary`."""
1987
# SimpleTerm(value, token=None, title=None)
1988
if dsp.publishing_history:
1989
binaries = dsp.publishing_history[0].getBuiltBinaries()
1990
summary = ', '.join(
1991
[binary.binary_package_name for binary in binaries])
1993
summary = "Not yet built."
1994
token = '%s-%s' % (dsp.distribution.name, dsp.name)
1995
return SimpleTerm(summary, token, dsp.name)
1997
def getTerm(self, dsp):
1998
"""See `IBaseVocabulary`."""
1999
return self.toTerm(dsp)
2001
def getTermByToken(self, token):
2002
"""See `IVocabularyTokenized`."""
2005
def searchForTerms(self, query=None):
2006
"""See `IHugeVocabulary`."""
2007
distribution = self.context
2010
search_term = unicode(query)
2011
store = IStore(SourcePackagePublishingHistory)
2013
SourcePackagePublishingHistory,
2015
SourcePackageRelease,
2016
SourcePackagePublishingHistory.sourcepackagereleaseID ==
2017
SourcePackageRelease.id),
2020
SourcePackageRelease.sourcepackagenameID ==
2021
SourcePackageName.id),
2024
SourcePackagePublishingHistory.distroseriesID ==
2028
BinaryPackageBuild.source_package_release_id ==
2029
SourcePackageRelease.id),
2031
BinaryPackageRelease,
2032
BinaryPackageRelease.buildID == BinaryPackageBuild.id),
2035
BinaryPackageRelease.binarypackagenameID ==
2036
BinaryPackageName.id
2039
DistroSeries.distributionID == distribution.id,
2040
SourcePackagePublishingHistory.status.is_in((
2041
PackagePublishingStatus.PENDING,
2042
PackagePublishingStatus.PUBLISHED)),
2043
SourcePackagePublishingHistory.archive ==
2044
distribution.main_archive,
2046
SourcePackageName.name.contains_string(search_term),
2047
BinaryPackageName.name.contains_string(
2048
search_term))).config(distinct=True)
2050
self.toTerm(distribution.getSourcePackage(spn)) for spn in spns]