~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Steve Kowalik
  • Date: 2011-08-07 04:05:52 UTC
  • mto: This revision was merged to the branch mainline in revision 13626.
  • Revision ID: stevenk@ubuntu.com-20110807040552-mwnxo0flmhvl35e8
Correct the notification based on review comments, and remove request{,ed}
from the function names, switching to create{,d}.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
__metaclass__ = type
9
9
 
10
10
import cgi
11
 
 
12
 
from lazr.restful.utils import safe_hasattr
13
11
import simplejson
14
12
from z3c.ptcompat import ViewPageTemplateFile
15
13
from zope.app.form.browser.itemswidgets import (
18
16
    )
19
17
from zope.schema.interfaces import IChoice
20
18
 
 
19
from canonical.launchpad.webapp import canonical_url
 
20
from canonical.lazr.utils import safe_hasattr
21
21
from lp.app.browser.stringformatter import FormattersAPI
22
22
from lp.app.browser.vocabulary import get_person_picker_entry_metadata
 
23
from lp.services.features import getFeatureFlag
23
24
from lp.services.propertycache import cachedproperty
24
 
from lp.services.webapp import canonical_url
25
 
from lp.services.webapp.vocabulary import IHugeVocabulary
26
25
 
27
26
 
28
27
class VocabularyPickerWidget(SingleDataHelper, ItemsWidgetBase):
139
138
            show_remove_button=self.show_remove_button,
140
139
            show_assign_me_button=self.show_assign_me_button,
141
140
            vocabulary_name=self.vocabulary_name,
142
 
            vocabulary_filters=self.vocabulary_filters,
143
141
            input_element=self.input_id)
144
142
 
145
143
    @property
158
156
        return None
159
157
 
160
158
    @property
161
 
    def vocabulary_filters(self):
162
 
        """The name of the field's vocabulary."""
163
 
        choice = IChoice(self.context)
164
 
        if choice.vocabulary is None:
165
 
            # We need the vocabulary to get the supported filters.
166
 
            raise ValueError(
167
 
                "The %r.%s interface attribute doesn't have its "
168
 
                "vocabulary specified."
169
 
                % (choice.context, choice.__name__))
170
 
        # Only IHugeVocabulary's have filters.
171
 
        if not IHugeVocabulary.providedBy(choice.vocabulary):
172
 
            return []
173
 
        supported_filters = choice.vocabulary.supportedFilters()
174
 
        # If we have no filters or just the ALL filter, then no filtering
175
 
        # support is required.
176
 
        filters = []
177
 
        if (len(supported_filters) == 0 or
178
 
           (len(supported_filters) == 1
179
 
            and supported_filters[0].name == 'ALL')):
180
 
            return filters
181
 
        for filter in supported_filters:
182
 
            filters.append({
183
 
                'name': filter.name,
184
 
                'title': filter.title,
185
 
                'description': filter.description,
186
 
                })
187
 
        return filters
188
 
 
189
 
    @property
190
159
    def vocabulary_name(self):
191
160
        """The name of the field's vocabulary."""
192
161
        choice = IChoice(self.context)
237
206
    include_create_team_link = False
238
207
    show_assign_me_button = True
239
208
    show_remove_button = False
240
 
    picker_type = 'person'
 
209
 
 
210
    @property
 
211
    def picker_type(self):
 
212
        # This is a method for now so we can block the use of the new
 
213
        # person picker js behind our picker_enhancments feature flag.
 
214
        if bool(getFeatureFlag('disclosure.picker_enhancements.enabled')):
 
215
            picker_type = 'person'
 
216
        else:
 
217
            picker_type = 'default'
 
218
        return picker_type
241
219
 
242
220
    @property
243
221
    def selected_value_metadata(self):