~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/launchpad/doc/vocabulary-json.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-06 02:52:27 UTC
  • mfrom: (13144.2.13 picker-click-item-detail)
  • Revision ID: launchpad@pqm.canonical.com-20110606025227-eplcb04k4ucufktz
[r=sinzui][bug=791116] Display links to a person's home page in
 launchpad when displaying search results in a person picker.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    >>> def print_json(json):
11
11
    ...     data = simplejson.loads(json)
12
12
    ...     print simplejson.dumps(data, sort_keys=True, indent=4)
13
 
    >>> def create_vocabulary_view(form):
 
13
    >>> def create_vocabulary_view(form, context=root):
14
14
    ...     # The BatchNavigator looks in the query string for GET requests.
15
15
    ...     query_string = urlencode(form)
16
 
    ...     return create_view(root, '+huge-vocabulary',
 
16
    ...     return create_view(context, '+huge-vocabulary',
17
17
    ...                        form=form, query_string=query_string)
18
18
 
19
19
The view requires the name of the vocabulary.
56
56
    {
57
57
        "entries": [
58
58
            {
 
59
                "alt_title": "guadamen",
 
60
                "alt_title_link": "http://launchpad.dev/~guadamen",
59
61
                "api_uri": "/~guadamen",
60
62
                "css": "sprite team",
61
 
                "title": "GuadaMen (guadamen)",
 
63
                "link_css": "js-action",
 
64
                "title": "GuadaMen",
62
65
                "value": "guadamen"
63
66
            }
64
67
        ],
84
87
    {
85
88
        "entries": [
86
89
            {
 
90
                "alt_title": "admins",
 
91
                "alt_title_link": "http://launchpad.dev/~admins",
87
92
                "api_uri": "/~admins",
88
93
                "css": "sprite team",
89
 
                "title": "Launchpad Administrators (admins)",
 
94
                "link_css": "js-action",
 
95
                "title": "Launchpad Administrators",
90
96
                "value": "admins"
91
97
            }
92
98
        ],
100
106
    {
101
107
        "entries": [
102
108
            {
 
109
                "alt_title": "name16",
 
110
                "alt_title_link": "http://launchpad.dev/~name16",
103
111
                "api_uri": "/~name16",
104
112
                "css": "sprite person",
105
113
                "description": "<email address hidden>",
106
 
                "title": "Foo Bar (name16)",
 
114
                "link_css": "js-action",
 
115
                "title": "Foo Bar",
107
116
                "value": "name16"
108
117
            }
109
118
        ],
110
119
        "total_size": 6
111
120
    }
112
121
 
 
122
If a person is affiliated with the view context, the relevant badge(s) will be
 
123
included in the picker entry.
 
124
 
 
125
    >>> from zope.component import getUtility
 
126
    >>> from lp.bugs.interfaces.bugtask import IBugTaskSet
 
127
    >>> bugtask = getUtility(IBugTaskSet).get(2)
 
128
    >>> form = dict(name='ValidPersonOrTeam', search_text='name12',
 
129
    ...             start='0', batch='1')
 
130
    >>> view = create_vocabulary_view(form, context=bugtask)
 
131
    >>> print_json(view())
 
132
    {
 
133
        "entries": [
 
134
            {
 
135
                "alt_title": "name12",
 
136
                "alt_title_link": "http://launchpad.dev/~name12",
 
137
                "api_uri": "/~name12",
 
138
                "badges": [
 
139
                     {
 
140
                         "alt": "Affiliated with Launchpad itself",
 
141
                         "url": "/@@/product-badge"
 
142
                     }
 
143
                 ],
 
144
                "css": "sprite person",
 
145
                "description": "<email address hidden>",
 
146
                "link_css": "js-action",
 
147
                "title": "Sample Person",
 
148
                "value": "name12"
 
149
            }
 
150
        ],
 
151
        "total_size": 1
 
152
    }
 
153
 
113
154
Long descriptions will be truncated.
114
155
 
115
156
    >>> form = dict(name='ProjectGroup', search_text='apache')
138
179
    {
139
180
        "entries": [
140
181
            {
 
182
                "alt_title": "name12",
 
183
                "alt_title_link": "http://launchpad.dev/~name12",
141
184
                "api_uri": "/~name12",
142
185
                "css": "sprite person",
143
186
                "description": "<email address hidden>",
144
 
                "title": "Sample Person (name12)",
 
187
                "link_css": "js-action",
 
188
                "title": "Sample Person",
145
189
                "value": "name12"
146
190
            }
147
191
        ],
157
201
    {
158
202
        "entries": [
159
203
            {
 
204
                "alt_title": "mark",
 
205
                "alt_title_link": "http://launchpad.dev/~mark",
160
206
                "api_uri": "/~mark",
161
207
                "css": "sprite person",
162
208
                "description": "<email address hidden> (mark on irc.freenode.net)",
163
 
                "title": "Mark Shuttleworth (mark)",
 
209
                "link_css": "js-action",
 
210
                "title": "Mark Shuttleworth",
164
211
                "value": "mark"
165
212
            }
166
213
        ],