1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
KarmaAction views
=================
>>> from lp.registry.interfaces.karma import IKarmaActionSet
>>> karmaactionset = getUtility(IKarmaActionSet)
Karma action set
----------------
The karma action set +index view lists all the karma actions.
>>> from canonical.launchpad.webapp.interfaces import ILaunchBag
>>> from canonical.launchpad.testing.pages import (
... extract_text, find_tag_by_id)
>>> user = getUtility(ILaunchBag).user
>>> view = create_view(karmaactionset, '+index', principal=user,
... path_info='/karmaaction')
>>> print extract_text(find_tag_by_id(view(), 'karmas'))
Category Action Points
bugs Bug Accepted 5
...
Karma action
------------
The karma action +edit view allow an admin to edit a karma action. The
view provides a label, page_title and a cancel_url
>>> action = karmaactionset.getByName('branchcreated')
>>> view = create_initialized_view(action, '+index')
>>> print view.label
Edit New branch registered karma action
>>> print view.page_title
Edit New branch registered karma action
>>> print view.cancel_url
http://launchpad.dev/karmaaction
The admin can edit the karma action's fields.
>>> view.field_names
['name', 'category', 'points', 'title', 'summary']
>>> action.points
1
>>> login('admin@canonical.com')
>>> form = {
... 'field.points': '2',
... 'field.actions.change': 'Change',
... }
>>> view = create_initialized_view(action, '+index', form=form)
>>> view.errors
[]
>>> print view.next_url
http://launchpad.dev/karmaaction
>>> action.points
2
Only admins can access the view.
>>> from canonical.launchpad.webapp.authorization import check_permission
>>> check_permission('launchpad.Admin', view)
True
>>> login('test@canonical.com')
>>> check_permission('launchpad.Admin', view)
False
|