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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
The Bugs front page
===================
The contents on the Bugs front page is driven by MaloneView. It
doesn't use its context for anything, so we don't have to supply one
when creating it.
>>> from lp.systemhomes import MaloneApplication
>>> from lp.services.webapp.servers import LaunchpadTestRequest
>>> from lp.bugs.browser.bug import MaloneView
>>> bugs_view = MaloneView(MaloneApplication(), LaunchpadTestRequest())
>>> bugs_view.initialize()
Recently Fixed Bugs
-------------------
There is a list of the most recently fixed bugs on the page. This list
is generated by getMostRecentlyFixedBugs(), which returns the ten most
recently fixed bugs, across all contexts. Only one bug is fixed in
Launchpad currently.
>>> from lp.bugs.interfaces.bugtask import BugTaskStatus
>>> from lp.bugs.model.bugtask import BugTask
>>> [bugtask.bug.id
... for bugtask in BugTask.selectBy(_status=BugTaskStatus.FIXRELEASED)]
[8]
>>> for bug in bugs_view.getMostRecentlyFixedBugs():
... print "%s: %s" % (bug.id, bug.title)
8: Printing doesn't work
Let's reopen it and close it again, to ensure that the date closed isn't
in the future.
>>> login('test@canonical.com')
>>> from lp.bugs.interfaces.bug import IBugSet
>>> bug_eight = getUtility(IBugSet).get(8)
>>> len(bug_eight.bugtasks)
1
>>> bug_eight.bugtasks[0].transitionToStatus(
... BugTaskStatus.CONFIRMED, bug_eight.bugtasks[0].distribution.owner)
>>> def fix_bug(bug_id, bugtask_index=0):
... bugtask = getUtility(IBugSet).get(bug_id).bugtasks[bugtask_index]
... bugtask.transitionToStatus(
... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
>>> fix_bug(8)
If we fix a few other bugs, these will turn up first in the list. It
doesn't matter which bugtask that gets fixed.
>>> fix_bug(1)
>>> fix_bug(2)
>>> fix_bug(4)
>>> for bug in bugs_view.getMostRecentlyFixedBugs():
... print "%s: %s" % (bug.id, bug.title)
4: Reflow problems with complex page layouts
2: Blackhole Trash folder
1: Firefox does not support SVG
8: Printing doesn't work
Even though a bug has several fixed bugtasks, it will only show up once
in the list. So if we fix another one of bug one's bugtasks, it will
simply appear on the top of the list.
>>> fix_bug(1, bugtask_index=1)
>>> for bug in bugs_view.getMostRecentlyFixedBugs():
... print "%s: %s" % (bug.id, bug.title)
1: Firefox does not support SVG
4: Reflow problems with complex page layouts
2: Blackhole Trash folder
8: Printing doesn't work
Only the bugs that the user has permission to view are shown in the
list, so if we mark bug #4 as private, No Privileges won't see it, since
he's not subscribed to it.
>>> bug_4 = getUtility(IBugSet).get(4)
>>> bug_4.setPrivate(True, getUtility(ILaunchBag).user)
True
>>> login('no-priv@canonical.com')
>>> bugs_view = MaloneView(MaloneApplication(), LaunchpadTestRequest())
>>> bugs_view.initialize()
>>> for bug in bugs_view.getMostRecentlyFixedBugs():
... print "%s: %s" % (bug.id, bug.title)
1: Firefox does not support SVG
2: Blackhole Trash folder
8: Printing doesn't work
If Person David gets subscribed to bug #4, he can see it in the list.
>>> from lp.registry.interfaces.person import IPersonSet
>>> person_set = getUtility(IPersonSet)
>>> login('foo.bar@canonical.com')
>>> bug_4.subscribe(
... person_set.getByEmail('david@canonical.com'),
... person_set.getByEmail('foo.bar@canonical.com'))
<lp.bugs.model.bugsubscription.BugSubscription ...>
>>> login('david@canonical.com')
>>> bugs_view = MaloneView(MaloneApplication(), LaunchpadTestRequest())
>>> bugs_view.initialize()
>>> for bug in bugs_view.getMostRecentlyFixedBugs():
... print "%s: %s" % (bug.id, bug.title)
1: Firefox does not support SVG
4: Reflow problems with complex page layouts
2: Blackhole Trash folder
8: Printing doesn't work
Only five bugs are returned by default:
>>> from lp.bugs.interfaces.bug import CreateBugParams
>>> from lp.registry.interfaces.product import IProductSet
>>> firefox = getUtility(IProductSet).getByName('firefox')
>>> for index in range(20):
... bug = firefox.createBug(CreateBugParams(
... getUtility(ILaunchBag).user, 'Test Bug #%s' % index,
... comment='Test bug #%s.' % index))
... bug.bugtasks[0].transitionToStatus(
... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
>>> len(bugs_view.getMostRecentlyFixedBugs())
5
|