~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/vocabulary.py

  • Committer: Stuart Bishop
  • Date: 2011-09-28 12:49:24 UTC
  • mfrom: (9893.10.1 trivial)
  • mto: This revision was merged to the branch mainline in revision 14178.
  • Revision ID: stuart.bishop@canonical.com-20110928124924-m5a22fymqghw6c5i
Merged trivial into distinct-db-users.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2011 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Bug domain vocabularies"""
 
5
 
 
6
__metaclass__ = type
 
7
__all__ = [
 
8
    'UsesBugsDistributionVocabulary',
 
9
    ]
 
10
 
 
11
from sqlobject import OR
 
12
 
 
13
from lp.registry.interfaces.distribution import IDistribution
 
14
from lp.registry.vocabularies import DistributionVocabulary
 
15
 
 
16
 
 
17
class UsesBugsDistributionVocabulary(DistributionVocabulary):
 
18
    """Distributions that use Launchpad to track bugs.
 
19
 
 
20
    If the context is a distribution, it is always included in the
 
21
    vocabulary. Historic data is not invalidated if a distro stops
 
22
    using Launchpad to track bugs. This vocabulary offers the correct
 
23
    choices of distributions at this moment.
 
24
    """
 
25
 
 
26
    def __init__(self, context=None):
 
27
        super(UsesBugsDistributionVocabulary, self).__init__(context=context)
 
28
        self.distribution = IDistribution(self.context, None)
 
29
 
 
30
    @property
 
31
    def _filter(self):
 
32
        if self.distribution is None:
 
33
            distro_id = 0
 
34
        else:
 
35
            distro_id = self.distribution.id
 
36
        return OR(
 
37
            self._table.q.official_malone == True,
 
38
            self._table.id == distro_id)