~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/doc/badges.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-22 04:23:31 UTC
  • mfrom: (14564.4.2 megalint-7)
  • Revision ID: launchpad@pqm.canonical.com-20111222042331-ldeo5z018n8bq6x1
[r=jtv][no-qa] Lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
= Badges =
 
1
Badges
 
2
======
2
3
 
3
4
Badges are nifty user interface elements that are used to indicate to
4
5
the user that there are interesting features about the thing that the
35
36
    security
36
37
 
37
38
 
38
 
== The Badge class ==
 
39
The Badge class
 
40
---------------
39
41
 
40
42
The badge class has two methods of interest:
41
43
  * renderIconImage - the HTML for the icon sized image
72
74
    ''
73
75
 
74
76
 
75
 
== IHasBadges ==
 
77
IHasBadges
 
78
----------
76
79
 
77
80
How to determine which badges to show for a given object is defined by
78
81
the IHasBadges interface.
137
140
    ...     print badge.alt
138
141
    Traceback (most recent call last):
139
142
    ...
140
 
    AttributeError: 'SimpleBadger' object has no attribute 'isBlueprintBadgeVisible'
141
 
 
142
 
 
143
 
 
144
 
== Preferred badging methodology ==
 
143
    AttributeError:
 
144
    'SimpleBadger' object has no attribute 'isBlueprintBadgeVisible'
 
145
 
 
146
 
 
147
 
 
148
Preferred badging methodology
 
149
-----------------------------
145
150
 
146
151
Under normal circumstances the badges for a given content object require
147
152
the accessing or counting of attributes and this almost always requires
217
222
    ...     print badge.renderIconImage()
218
223
    Foo.bugs
219
224
    Foo.blueprints
220
 
    <img alt="bug" width="14" height="14" src="/@@/bug" title="Linked to a bug"/>
 
225
    <img alt="bug" width="14" height="14" src="/@@/bug"
 
226
    title="Linked to a bug"/>
221
227
 
222
228
When showing listings of Foos, you often want to use
223
229
`lazr.delegates.delegates`. By having the DelegatingFoo inherit from the
259
265
 
260
266
    >>> for badge in badger.getVisibleBadges():
261
267
    ...     print badge.renderIconImage()
262
 
    <img alt="bug" width="14" height="14" src="/@@/bug" title="Linked to a bug"/>
263
 
 
264
 
 
265
 
== Tales expressions ==
 
268
    <img alt="bug" width="14" height="14" src="/@@/bug"
 
269
    title="Linked to a bug"/>
 
270
 
 
271
 
 
272
Tales expressions
 
273
-----------------
266
274
 
267
275
There is a tales formatter defined for badges.  These can be shown
268
276
as either small or large.