~gmb/launchpad/bug-644346

« back to all changes in this revision

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

  • Committer: Graham Binns
  • Date: 2010-09-23 08:59:28 UTC
  • mfrom: (11575.1.37 launchpad)
  • Revision ID: graham@canonical.com-20100923085928-4x8vlt72gvzppb11
Merged devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    SLAVE_FLAVOR,
64
64
    )
65
65
from lp.app.errors import NotFoundError
 
66
from lp.app.enums import (
 
67
    ServiceUsage,
 
68
    service_uses_launchpad)
 
69
from lp.app.interfaces.launchpad import IServiceUsage
66
70
from lp.blueprints.interfaces.specification import (
67
71
    SpecificationFilter,
68
72
    SpecificationGoalStatus,
186
190
    """A particular series of a distribution."""
187
191
    implements(
188
192
        ICanPublishPackages, IDistroSeries, IHasBugHeat, IHasBuildRecords,
189
 
        IHasQueueItems)
 
193
        IHasQueueItems, IServiceUsage)
190
194
 
191
195
    _table = 'DistroSeries'
192
196
    _defaultOrder = ['distribution', 'version']
263
267
            """ % self.id,
264
268
            clauseTables=["ComponentSelection"])
265
269
 
 
270
    @property
 
271
    def answers_usage(self):
 
272
        """See `IServiceUsage.`"""
 
273
        return self.distribution.answers_usage
 
274
 
 
275
    @property
 
276
    def blueprints_usage(self):
 
277
        """See `IServiceUsage.`"""
 
278
        return self.distribution.blueprints_usage
 
279
 
 
280
    @property
 
281
    def translations_usage(self):
 
282
        """See `IServiceUsage.`"""
 
283
        # If translations_usage is set for the Distribution, respect it.
 
284
        usage = self.distribution.translations_usage
 
285
        if usage != ServiceUsage.UNKNOWN:
 
286
            return usage
 
287
 
 
288
        # If not, usage is based on the presence of current translation
 
289
        # templates for the series.
 
290
        if self.getCurrentTranslationTemplates().count() > 0:
 
291
            return ServiceUsage.LAUNCHPAD
 
292
        else:
 
293
            return ServiceUsage.UNKNOWN
 
294
 
 
295
    @property
 
296
    def codehosting_usage(self):
 
297
        """See `IServiceUsage.`"""
 
298
        return self.distribution.codehosting_usage
 
299
 
 
300
    @property
 
301
    def bug_tracking_usage(self):
 
302
        """See `IServiceUsage.`"""
 
303
        return self.distribution.bug_tracking_usage
 
304
 
 
305
    @property
 
306
    def uses_launchpad(self):
 
307
        """ See `IServiceUsage.`"""
 
308
        return (
 
309
            service_uses_launchpad(self.blueprints_usage) or
 
310
            service_uses_launchpad(self.translations_usage) or
 
311
            service_uses_launchpad(self.answers_usage) or
 
312
            service_uses_launchpad(self.codehosting_usage) or
 
313
            service_uses_launchpad(self.bug_tracking_usage))
 
314
 
266
315
    # DistroArchSeries lookup properties/methods.
267
316
    architectures = SQLMultipleJoin(
268
317
        'DistroArchSeries', joinColumn='distroseries',
694
743
        """Customize `search_params` for this distribution series."""
695
744
        search_params.setDistroSeries(self)
696
745
 
 
746
    def _getOfficialTagClause(self):
 
747
        return self.distribution._getOfficialTagClause()
 
748
 
697
749
    @property
698
750
    def official_bug_tags(self):
699
751
        """See `IHasBugs`."""