~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/browser/vocabulary.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-04 20:34:35 UTC
  • mfrom: (13608.1.4 person-picker-expand-1)
  • Revision ID: launchpad@pqm.canonical.com-20110804203435-o5cob6ra9jw8hev1
[r=jcsackett][bug=800361,
        798759] Restore picker expander and place it behind its own flag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from canonical.launchpad.webapp.interfaces import NoCanonicalUrl
33
33
from canonical.launchpad.webapp.publisher import canonical_url
34
34
from lp.app.browser.tales import (
 
35
    DateTimeFormatterAPI,
35
36
    IRCNicknameFormatterAPI,
36
37
    ObjectImageDisplayAPI,
37
38
    )
61
62
    css = Attribute('CSS Class')
62
63
    alt_title = Attribute('Alternative title')
63
64
    title_link = Attribute('URL used for anchor on title')
 
65
    details = Attribute('An optional list of information about the entry')
64
66
    alt_title_link = Attribute('URL used for anchor on alt title')
65
67
    link_css = Attribute('CSS Class for links')
66
68
    badges = Attribute('List of badge img attributes')
72
74
    implements(IPickerEntry)
73
75
 
74
76
    def __init__(self, description=None, image=None, css=None, alt_title=None,
75
 
                 title_link=None, alt_title_link=None, link_css='js-action',
76
 
                 badges=None, metadata=None):
 
77
                 title_link=None, details=None, alt_title_link=None,
 
78
                 link_css='sprite new-window', badges=None, metadata=None):
77
79
        self.description = description
78
80
        self.image = image
79
81
        self.css = css
80
82
        self.alt_title = alt_title
81
83
        self.title_link = title_link
 
84
        self.details = details
82
85
        self.alt_title_link = alt_title_link
83
86
        self.link_css = link_css
84
87
        self.badges = badges
137
140
                extra.badges = [
138
141
                    dict(url=badge_info.url, alt=badge_info.alt_text)]
139
142
 
 
143
        picker_expander_enabled = kwarg.get('picker_expander_enabled', False)
 
144
        if picker_expander_enabled:
 
145
            extra.details = []
 
146
 
140
147
        if person.preferredemail is not None:
141
148
            if person.hide_email_addresses:
142
149
                extra.description = '<email address hidden>'
161
168
                irc_nicks = ", ".join(
162
169
                    [IRCNicknameFormatterAPI(ircid).displayname()
163
170
                    for ircid in person.ircnicknames])
164
 
            if irc_nicks:
 
171
            if irc_nicks and not picker_expander_enabled:
165
172
                if extra.description:
166
173
                    extra.description = ("%s (%s)" %
167
174
                        (extra.description, irc_nicks))
168
175
                else:
169
176
                    extra.description = "%s" % irc_nicks
 
177
            if picker_expander_enabled:
 
178
                if irc_nicks:
 
179
                    extra.details.append(irc_nicks)
 
180
                if person.is_team:
 
181
                    extra.details.append(
 
182
                        'Team members: %s' % person.all_member_count)
 
183
                else:
 
184
                    extra.details.append(
 
185
                        'Member since %s' % DateTimeFormatterAPI(
 
186
                            person.datecreated).date())
170
187
 
171
188
        return extra
172
189
 
223
240
        self.request = request
224
241
        self.enhanced_picker_enabled = bool(
225
242
            getFeatureFlag('disclosure.picker_enhancements.enabled'))
 
243
        self.picker_expander_enabled = bool(
 
244
            getFeatureFlag('disclosure.picker_expander.enabled'))
226
245
 
227
246
    def __call__(self):
228
247
        name = self.request.form.get('name')
267
286
                entry['api_uri'] = 'Could not find canonical url.'
268
287
            picker_entry = IPickerEntry(term.value).getPickerEntry(
269
288
                self.context,
270
 
                enhanced_picker_enabled=self.enhanced_picker_enabled)
 
289
                enhanced_picker_enabled=self.enhanced_picker_enabled,
 
290
                picker_expander_enabled=self.picker_expander_enabled)
271
291
            if picker_entry.description is not None:
272
292
                if len(picker_entry.description) > MAX_DESCRIPTION_LENGTH:
273
293
                    entry['description'] = (
283
303
                entry['alt_title'] = picker_entry.alt_title
284
304
            if picker_entry.title_link is not None:
285
305
                entry['title_link'] = picker_entry.title_link
 
306
            if picker_entry.details is not None:
 
307
                entry['details'] = picker_entry.details
286
308
            if picker_entry.alt_title_link is not None:
287
309
                entry['alt_title_link'] = picker_entry.alt_title_link
288
310
            if picker_entry.link_css is not None: