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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
= Editing Email Address bugtasks =
>>> import transaction
>>> from zope.component import getUtility
>>> from lp.registry.interfaces.person import IPersonSet
>>> from lp.registry.interfaces.product import IProductSet
>>> from lp.testing import ANONYMOUS, login, logout
>>> from zope.security.proxy import removeSecurityProxy
>>> def widget_visibility(user, url):
... naked_user = removeSecurityProxy(user)
... naked_email = removeSecurityProxy(user.preferredemail)
... browser = setupBrowser(
... "Basic %s:test" % naked_email.email)
... transaction.commit()
... logout()
... browser.open(url)
... try:
... browser.getControl("Status")
... except LookupError:
... status = False
... else:
... status = True
... try:
... browser.getControl("Importance")
... except LookupError:
... importance = False
... else:
... importance = True
... return status, importance
>>> def print_widget_visibility(user, url):
... status, importance = widget_visibility(user, url)
... print 'Status: %s\nImportance: %s' % (status, importance)
== "Normal" (not Email Address) bugtasks ==
Normally, it's not possible to edit the status or importance of a
bugtask associated with a bugwatch that is linked to an external bug
tracker, because status and importance are updated by checkwatches.
To prepare, we must add a task that references a bug tracked
elsewhere:
>>> user_browser.open('http://bugs.launchpad.dev/'
... 'jokosher/+bug/12/+choose-affected-product')
>>> user_browser.getControl('Project').value = u'gnome-terminal'
>>> user_browser.getControl('Continue').click()
>>> user_browser.getControl('I have the URL').selected = True
>>> user_browser.getControl(name='field.bug_url').value = (
... u'http://mantis.bugtracker/view.php?id=1234')
>>> user_browser.getControl('Add to Bug Report').click()
>>> user_browser.getControl(
... 'Register Bug Tracker and Add to Bug Report').click()
>>> user_browser.url
'http://bugs.launchpad.dev/gnome-terminal/+bug/12'
The product owner cannot see the Status or Importance widgets:
>>> login("foo.bar@canonical.com")
>>> gnome_terminal = getUtility(IProductSet).getByName("gnome-terminal")
>>> login(ANONYMOUS)
>>> gnome_terminal.owner.name
u'name12'
>>> print_widget_visibility(
... user=gnome_terminal.owner,
... url=('http://bugs.launchpad.dev/'
... 'gnome-terminal/+bug/12/+editstatus'))
Status: False
Importance: False
Nor can an ordinary user:
>>> login("foo.bar@canonical.com")
>>> no_priv = getUtility(IPersonSet).getByName("no-priv")
>>> print_widget_visibility(
... user=no_priv,
... url=('http://bugs.launchpad.dev/'
... 'gnome-terminal/+bug/12/+editstatus'))
Status: False
Importance: False
And the bug supervisor can't see the widgets either.
>>> login("foo.bar@canonical.com")
>>> gnome_terminal.setBugSupervisor(no_priv, no_priv)
>>> print_widget_visibility(
... user=no_priv,
... url=('http://bugs.launchpad.dev/'
... 'gnome-terminal/+bug/12/+editstatus'))
Status: False
Importance: False
== Email Address bugtasks ==
The status and importance of a bugtask with an email address bugwatch
will be editable.
To prepare, we add a task that references a bug that's tracked by
email:
>>> user_browser.open('http://bugs.launchpad.dev/'
... 'gnome-terminal/+bug/12/+choose-affected-product')
>>> user_browser.getControl('Project').value = u'alsa-utils'
>>> user_browser.getControl('Continue').click()
>>> user_browser.getControl('I have already emailed').selected = True
>>> user_browser.getControl(
... name='field.upstream_email_address_done').value = (
... u'bugs@example.com')
>>> user_browser.getControl('Add to Bug Report').click()
>>> user_browser.url
'http://bugs.launchpad.dev/alsa-utils/+bug/12'
The owner can see the Status and Importance widgets.
>>> login("foo.bar@canonical.com")
>>> alsa_utils = getUtility(IProductSet).getByName("alsa-utils")
>>> login(ANONYMOUS)
>>> alsa_utils.owner.name
u'mark'
>>> print_widget_visibility(
... user=alsa_utils.owner,
... url=('http://bugs.launchpad.dev/'
... 'alsa-utils/+bug/12/+editstatus'))
Status: True
Importance: True
An ordinary user can see the Status widget. He can't see the
Importance widget because he would not normally be permitted to alter
the importance of a bugtask in Alsa Utils.
>>> login("foo.bar@canonical.com")
>>> no_priv = getUtility(IPersonSet).getByName("no-priv")
>>> print_widget_visibility(
... user=no_priv,
... url=('http://bugs.launchpad.dev/'
... 'alsa-utils/+bug/12/+editstatus'))
Status: True
Importance: False
A bug supervisor can see both.
>>> login("foo.bar@canonical.com")
>>> alsa_utils.setBugSupervisor(no_priv, no_priv)
>>> print_widget_visibility(
... user=no_priv,
... url=('http://bugs.launchpad.dev/'
... 'alsa-utils/+bug/12/+editstatus'))
Status: True
Importance: True
|