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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
= Bugs Fixed Elsewhere =
The +bugtarget-portlet-bugfilters-info view for a distribution or
product contains a property for a URL to a list of bugs fixed
elsewhere.
>>> from zope.component import getMultiAdapter
>>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
>>> view = getMultiAdapter(
... (bugtarget, LaunchpadTestRequest()),
... name='+bugtarget-portlet-bugfilters-info')
>>> view.initialize()
>>> view.bugs_fixed_elsewhere_url
u'http://.../+bugs?field.status_upstream=resolved_upstream'
The +bugtarget-portlet-bugfilters-stats view for a distribution or
product contains the URL as above in addition to a count of how many
bugs that are fixed elsewhere. This count can take a while to
calculate, so it is put on this separate view which can be requested
asyncronously.
>>> def get_view():
... view = getMultiAdapter(
... (bugtarget, LaunchpadTestRequest()),
... name='+bugtarget-portlet-bugfilters-stats')
... view.initialize()
... return view
>>> view = get_view()
>>> view.bugs_fixed_elsewhere_url
u'http://.../+bugs?field.status_upstream=resolved_upstream'
>>> view.bugs_fixed_elsewhere_count
0
Simply opening a bug elsewhere won't increase the count.
>>> from lp.registry.interfaces.product import IProductSet
>>> evolution = getUtility(IProductSet).getByName('evolution')
>>> evolution != bugtarget
True
>>> bug = filebug(bugtarget, 'Example Bug')
>>> from lp.bugs.interfaces.bugtask import IBugTaskSet
>>> elsewhere = getUtility(IBugTaskSet).createTask(
... bug, owner=getUtility(ILaunchBag).user, product=evolution)
>>> get_view().bugs_fixed_elsewhere_count
0
But if we mark the bug as fixed in the other, the count will increase
by one.
>>> from lp.bugs.interfaces.bugtask import BugTaskStatus
>>> elsewhere.transitionToStatus(
... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
>>> get_view().bugs_fixed_elsewhere_count
1L
Bugs fixed elsewhere also show up when we perform an advanced bug
search, using the appropriate query string parameter to ask for "bugs
resolved elsewhere":
>>> search_view = getMultiAdapter(
... (bugtarget,
... LaunchpadTestRequest(
... form={'field.status_upstream': 'resolved_upstream'})),
... name='+bugs')
>>> search_view.initialize()
>>> navigator = search_view.search()
>>> for task in search_view.search().batch:
... for related_task in task.related_tasks:
... print related_task.target.name
... print related_task.status.name
evolution
FIXRELEASED
== Private Bugs ==
Only bugs that the user has permission to view are included in the count.
>>> another_bug = filebug(bugtarget, 'Example Bug')
>>> another_bug.setPrivate(True, getUtility(ILaunchBag).user)
True
>>> another_elsewhere = getUtility(IBugTaskSet).createTask(
... another_bug, owner=getUtility(ILaunchBag).user, product=evolution)
>>> another_elsewhere.transitionToStatus(
... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
>>> get_view().bugs_fixed_elsewhere_count
2L
This means that No Privileges Person will see that there is only one bug
fixed elsewhere.
>>> login('no-priv@canonical.com')
>>> get_view().bugs_fixed_elsewhere_count
1L
If the private bug is made public again, he will of course see that
there are two bugs fixed.
>>> login('foo.bar@canonical.com')
>>> another_bug.setPrivate(False, getUtility(ILaunchBag).user)
True
>>> login('no-priv@canonical.com')
>>> get_view().bugs_fixed_elsewhere_count
2L
== Duplicate Bugs ==
Bugs that are duplicate of other bugs aren't included in the count.
>>> another_bug.markAsDuplicate(bug)
>>> get_view().bugs_fixed_elsewhere_count
1L
== Resolved Bugs ==
The count includes only bugs that are open in the current context.
>>> for bugtask in bug.bugtasks:
... if bugtask.target == bugtarget:
... break
... else:
... print "Couldn't find a bugtasks for %r" % bugtarget
>>> bugtask.transitionToStatus(
... BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
>>> get_view().bugs_fixed_elsewhere_count
0
|