~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/widgets/popup.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-21 21:32:29 UTC
  • mfrom: (13635.3.18 filter-target-pickers)
  • Revision ID: launchpad@pqm.canonical.com-20110821213229-mya8li508jpsj2qw
[r=sinzui][bug=820011] Wire up the vocab filtering capability to the
 pickers to allow picker search results to be filtered using named vocab
 filters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
            show_remove_button=self.show_remove_button,
139
139
            show_assign_me_button=self.show_assign_me_button,
140
140
            vocabulary_name=self.vocabulary_name,
 
141
            vocabulary_filters=self.vocabulary_filters,
141
142
            input_element=self.input_id)
142
143
 
143
144
    @property
156
157
        return None
157
158
 
158
159
    @property
 
160
    def vocabulary_filters(self):
 
161
        """The name of the field's vocabulary."""
 
162
        choice = IChoice(self.context)
 
163
        if choice.vocabulary is None:
 
164
            # We need the vocabulary to get the supported filters.
 
165
            raise ValueError(
 
166
                "The %r.%s interface attribute doesn't have its "
 
167
                "vocabulary specified."
 
168
                % (choice.context, choice.__name__))
 
169
        supported_filters = choice.vocabulary.supportedFilters()
 
170
        # If we have no filters or just the ALL filter, then no filtering
 
171
        # support is required.
 
172
        filters = []
 
173
        if (len(supported_filters) == 0 or
 
174
           (len(supported_filters) == 1
 
175
            and supported_filters[0].name == 'ALL')):
 
176
            return filters
 
177
        for filter in supported_filters:
 
178
            filters.append({
 
179
                'name': filter.name,
 
180
                'title': filter.title,
 
181
                'description': filter.description,
 
182
                })
 
183
        return filters
 
184
 
 
185
    @property
159
186
    def vocabulary_name(self):
160
187
        """The name of the field's vocabulary."""
161
188
        choice = IChoice(self.context)