Merge lp:~brian-murray/launchpad/modify-official-bug-tags-permissions into lp:launchpad

Proposed by Brian Murray
Status: Merged
Approved by: Brian Murray
Approved revision: no longer in the source branch.
Merged at revision: 11701
Proposed branch: lp:~brian-murray/launchpad/modify-official-bug-tags-permissions
Merge into: lp:launchpad
Diff against target: 354 lines (+163/-65)
7 files modified
lib/canonical/launchpad/permissions.zcml (+5/-0)
lib/canonical/launchpad/security.py (+19/-4)
lib/lp/bugs/browser/bugtarget.py (+1/-1)
lib/lp/bugs/browser/configure.zcml (+1/-1)
lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt (+18/-1)
lib/lp/bugs/stories/webservice/xx-bug-target.txt (+23/-0)
lib/lp/registry/configure.zcml (+96/-58)
To merge this branch: bzr merge lp:~brian-murray/launchpad/modify-official-bug-tags-permissions
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) code Approve
Review via email: mp+37758@code.launchpad.net

Commit message

Allow a project's or distribution's bug supervisor to set the official bug tags for it.

Description of the change

This branch creates a new permission launchpad.BugSupervisor and grants a project's bug supervisor the ability to set official bug tags for that project. The launchpad.BugSupervisor position will also be used in other places for example setting the bug reporting guidelines and bug reported acknowledgment.

The launchpad.BugSupervisor permission was discussed with Curtis, in #launchpad-dev, who thought it was a good idea.

I've added a test to xx-official-bug-tags.txt to ensure that the +manage-official-tags link appears for a bug supervisor.

bin/test -cvvt xx-official-bug-tags.txt

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :
Download full text (5.3 KiB)

Hi Brian,

This branch looks good. I have a few comments below for changes I would like.

-Edwin

>=== modified file 'lib/canonical/launchpad/security.py'
>--- lib/canonical/launchpad/security.py 2010-09-14 18:28:53 +0000
>+++ lib/canonical/launchpad/security.py 2010-10-06 17:27:19 +0000
>@@ -61,6 +61,7 @@
> IBuildFarmJobOld,
> )
> from lp.buildmaster.interfaces.packagebuild import IPackageBuild
>+from lp.bugs.interfaces.bugtarget import IOfficialBugTagTargetRestricted
> from lp.code.interfaces.branch import (
> IBranch,
> user_has_special_branch_access,
>@@ -656,7 +657,7 @@
>
> def checkAuthenticated(self, user):
> """Only the Launchpad admins need this, we are only going to use it
>- for connecting up series and distroseriess where we did not have
>+ for connecting up series and distroseries where we did not have
> them."""

According to PEP8, if the docstring is more than one line, the
ending triple-quotes should appear on a line by itself.

> return user.in_admin
>
>@@ -897,6 +898,18 @@
> user.in_admin)
>
>
>+class EditProductOfficialBugTagsByOwnerBugSupervisorOrAdmins(AuthorizationBase):

This line is too long. It can be wrapped like
AdminDistroSeriesLanguagePacks.

>+ """The owner of a product and its bug supervisor should be able to
>+ edit its official bug tags."""

The first sentence of the docstring should fit on a single line, and
there should be a blank line separating it from any additional text.

>+ permission = 'launchpad.BugSupervisor'
>+ usedfor = IOfficialBugTagTargetRestricted
>+
>+ def checkAuthenticated(self, user):
>+ return (user.inTeam(self.obj.bug_supervisor) or
>+ user.inTeam(self.obj.owner) or
>+ user.in_admin)
>+
>+
> class AdminDistroSeries(AdminByAdminsTeam):
> """Soyuz involves huge chunks of data in the archive and librarian,
> so for the moment we are locking down admin and edit on distributions
>=== modified file 'lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt'
>--- lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt 2010-10-03 15:30:06 +0000
>+++ lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt 2010-10-06 17:27:19 +0000
>@@ -52,13 +52,32 @@
> ...
> Unauthorized...
>
>+The link is also available for the bug supervisor.
>+
>+ >>> from lp.testing.sampledata import ADMIN_EMAIL
>+ >>> from canonical.launchpad.ftests import login, logout
>+ >>> login(ADMIN_EMAIL)
>+ >>> d_owner = factory.makePerson()
>+ >>> logout()
>+ >>> login_person(d_owner)
>+ >>> distro = factory.makeDistribution(name='youbuntu', owner=d_owner)
>+ >>> supervisor_team = factory.makeTeam(owner=d_owner)
>+ >>> supervisor_member = factory.makePerson(password='g00dpassword')
>+ >>> added = supervisor_team.addMember(supervisor_member, d_owner)
>+ >>> distro.setBugSupervisor(supervisor_team, d_owner)
>+ >>> bug_super_browser = setupBrowser(
>+ ... auth='Basic %s:g00dpassword' %
>+ ... supervisor_member.preferredemail.email)
>+ >>> logout()
>+ >>> bug_super_browser.open(
>+ ... 'http://bugs.launchpad.dev/youbuntu/+...

Read more...

review: Approve (code)
Revision history for this message
Robert Collins (lifeless) wrote :

Wouldn't it be usual to check for Launchpad.Edit on context.official_tags ?

This branch adds a special case that isn't needed; better to change
how Edit is obtained for the tags object.

Or perhaps I misunderstand how things are structured.

-Rob

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/permissions.zcml'
2--- lib/canonical/launchpad/permissions.zcml 2010-08-13 21:30:24 +0000
3+++ lib/canonical/launchpad/permissions.zcml 2010-10-14 17:02:44 +0000
4@@ -67,6 +67,11 @@
5 access_level="write" />
6
7 <permission
8+ id="launchpad.BugSupervisor"
9+ title="The role of managing bugs and bug rules for a product."
10+ access_level="write" />
11+
12+ <permission
13 id="launchpad.Owner"
14 title="The role of someone who created or otherwise owns an object."
15 access_level="write" />
16
17=== modified file 'lib/canonical/launchpad/security.py'
18--- lib/canonical/launchpad/security.py 2010-10-04 19:55:15 +0000
19+++ lib/canonical/launchpad/security.py 2010-10-14 17:02:44 +0000
20@@ -61,6 +61,7 @@
21 IBuildFarmJobOld,
22 )
23 from lp.buildmaster.interfaces.packagebuild import IPackageBuild
24+from lp.bugs.interfaces.bugtarget import IOfficialBugTagTargetRestricted
25 from lp.code.interfaces.branch import (
26 IBranch,
27 user_has_special_branch_access,
28@@ -655,9 +656,10 @@
29 usedfor = IMilestone
30
31 def checkAuthenticated(self, user):
32- """Only the Launchpad admins need this, we are only going to use it
33- for connecting up series and distroseriess where we did not have
34- them."""
35+ """Only the Launchpad admins need this, we are only going to use
36+ it for connecting up series and distroseries where we did not
37+ have them.
38+ """
39 return user.in_admin
40
41
42@@ -898,6 +900,19 @@
43 user.in_admin)
44
45
46+class EditProductOfficialBugTagsByOwnerOrBugSupervisorOrAdmins(
47+ AuthorizationBase):
48+ """Product's owner and bug supervisor can set official bug tags."""
49+
50+ permission = 'launchpad.BugSupervisor'
51+ usedfor = IOfficialBugTagTargetRestricted
52+
53+ def checkAuthenticated(self, user):
54+ return (user.inTeam(self.obj.bug_supervisor) or
55+ user.inTeam(self.obj.owner) or
56+ user.in_admin)
57+
58+
59 class AdminDistroSeries(AdminByAdminsTeam):
60 """Soyuz involves huge chunks of data in the archive and librarian,
61 so for the moment we are locking down admin and edit on distributions
62@@ -1930,7 +1945,7 @@
63 def checkAuthenticated(self, user):
64 """Can the user view the submission details?
65
66- Submissions that not marked private are publicly visible,
67+ Submissions that are not marked private are publicly visible,
68 private submissions may only be accessed by their owner and by
69 admins.
70 """
71
72=== modified file 'lib/lp/bugs/browser/bugtarget.py'
73--- lib/lp/bugs/browser/bugtarget.py 2010-10-04 06:20:04 +0000
74+++ lib/lp/bugs/browser/bugtarget.py 2010-10-14 17:02:44 +0000
75@@ -1384,7 +1384,7 @@
76 def show_manage_tags_link(self):
77 """Should a link to a "manage official tags" page be shown?"""
78 return (IOfficialBugTagTargetRestricted.providedBy(self.context) and
79- check_permission('launchpad.Edit', self.context))
80+ check_permission('launchpad.BugSupervisor', self.context))
81
82
83 class OfficialBugTagsManageView(LaunchpadEditFormView):
84
85=== modified file 'lib/lp/bugs/browser/configure.zcml'
86--- lib/lp/bugs/browser/configure.zcml 2010-10-03 15:30:06 +0000
87+++ lib/lp/bugs/browser/configure.zcml 2010-10-14 17:02:44 +0000
88@@ -112,7 +112,7 @@
89 for="lp.bugs.interfaces.bugtarget.IOfficialBugTagTargetRestricted"
90 class="lp.bugs.browser.bugtarget.OfficialBugTagsManageView"
91 facet="bugs"
92- permission="launchpad.Edit"
93+ permission="launchpad.BugSupervisor"
94 template="../templates/official-bug-target-manage-tags.pt"/>
95 <browser:page
96 name="+patches"
97
98=== modified file 'lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt'
99--- lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt 2010-10-03 15:30:06 +0000
100+++ lib/lp/bugs/stories/bug-tags/xx-official-bug-tags.txt 2010-10-14 17:02:44 +0000
101@@ -52,13 +52,30 @@
102 ...
103 Unauthorized...
104
105+The link is also available for the bug supervisor.
106+
107+ >>> from lp.testing.sampledata import ADMIN_EMAIL
108+ >>> from canonical.launchpad.ftests import login, logout
109+ >>> login(ADMIN_EMAIL)
110+ >>> supervisor = factory.makePerson(password='g00dpassword')
111+ >>> youbuntu = factory.makeProduct(name='youbuntu',
112+ ... bug_supervisor=supervisor,
113+ ... official_malone=True)
114+ >>> bug_super_browser = setupBrowser(
115+ ... auth='Basic %s:g00dpassword' %
116+ ... supervisor.preferredemail.email)
117+ >>> logout()
118+ >>> bug_super_browser.open(
119+ ... 'http://bugs.launchpad.dev/youbuntu')
120+ >>> bug_super_browser.getLink('Edit official tags').click()
121+ >>> print bug_super_browser.url
122+ http://bugs.launchpad.dev/youbuntu/+manage-official-tags
123
124 == Official Tags on Bug Pages ==
125
126 Official tags are displayed using a different style from unofficial ones.
127 They are grouped together at the beginning of the list.
128
129- >>> from canonical.launchpad.ftests import login, logout
130 >>> from canonical.launchpad.webapp import canonical_url
131 >>> from lp.bugs.tests.bug import print_bug_tag_anchors
132 >>> import transaction
133
134=== modified file 'lib/lp/bugs/stories/webservice/xx-bug-target.txt'
135--- lib/lp/bugs/stories/webservice/xx-bug-target.txt 2010-10-03 15:30:06 +0000
136+++ lib/lp/bugs/stories/webservice/xx-bug-target.txt 2010-10-14 17:02:44 +0000
137@@ -87,6 +87,29 @@
138 ...
139 <BLANKLINE>
140
141+The bug supervisor of a product can also add tags.
142+
143+ >>> login('foo.bar@canonical.com')
144+ >>> salgado = getUtility(IPersonSet).getByName('salgado')
145+ >>> product = factory.makeProduct(name='tags-test-product2')
146+ >>> logout()
147+ >>> ws_salgado = webservice.get('/~salgado').jsonBody()
148+ >>> print webservice.patch(
149+ ... '/tags-test-product2', 'application/json',
150+ ... dumps({'bug_supervisor_link': ws_salgado['self_link']}))
151+ HTTP/1.1 209 Content Returned...
152+
153+The webservice client is logged in as salgado and he can add a new official
154+tag.
155+
156+ >>> print webservice.named_post(
157+ ... '/tags-test-product2', 'addOfficialBugTag',
158+ ... tag='test-bug-tag2')
159+ HTTP/1.1 200 Ok
160+ ...
161+ <BLANKLINE>
162+ null
163+
164 Official tags must conform to the same format as ordinary tags.
165
166 >>> print webservice.named_post(
167
168=== modified file 'lib/lp/registry/configure.zcml'
169--- lib/lp/registry/configure.zcml 2010-10-07 21:07:40 +0000
170+++ lib/lp/registry/configure.zcml 2010-10-14 17:02:44 +0000
171@@ -409,52 +409,52 @@
172
173 <allow
174 attributes="
175- distribution
176- development_version
177- sourcepackagename
178- name
179- displayname
180- title
181- summary
182- distro
183- get_distroseries_packages
184- subscribers
185- currentrelease
186- releases
187- publishing_history
188- current_publishing_records
189- bug_reporting_guidelines
190- bug_reported_acknowledgement
191- latest_overall_publication
192+ __eq__
193 __getitem__
194- getVersion
195- __eq__
196 __ne__
197+ _getOfficialTagClause
198+ all_bugtasks
199+ bug_count
200+ bug_reported_acknowledgement
201+ bug_reporting_guidelines
202+ bugtargetdisplayname
203+ bugtargetname
204 bugtasks
205- searchTasks
206- open_bugtasks
207 closed_bugtasks
208 critical_bugtasks
209+ current_publishing_records
210+ currentrelease
211+ development_version
212+ displayname
213+ distribution
214+ distro
215+ findRelatedArchivePublications
216+ findRelatedArchives
217+ getBugCounts
218+ getPersonsByEmail
219+ getReleasesAndPublishingHistory
220+ getUsedBugTags
221+ getUsedBugTagsWithOpenCounts
222+ getVersion
223+ get_distroseries_packages
224+ has_bugtasks
225 high_bugtasks
226 inprogress_bugtasks
227- unassigned_bugtasks
228+ latest_overall_publication
229+ name
230 new_bugtasks
231- all_bugtasks
232- has_bugtasks
233- getUsedBugTags
234- getUsedBugTagsWithOpenCounts
235- bugtargetdisplayname
236- bugtargetname
237- getBugCounts
238- bug_count
239+ official_bug_tags
240+ open_bugtasks
241+ publishing_history
242+ releases
243+ searchTasks
244+ sourcepackagename
245+ subscribers
246+ summary
247+ title
248 total_bug_heat
249- getPersonsByEmail
250- getReleasesAndPublishingHistory
251- upstream_product
252- _getOfficialTagClause
253- official_bug_tags
254- findRelatedArchives
255- findRelatedArchivePublications"/>
256+ unassigned_bugtasks
257+ upstream_product"/>
258 <require
259 permission="launchpad.AnyPerson"
260 attributes="createBug"/>
261@@ -1130,21 +1130,44 @@
262 set_schema="lp.app.interfaces.launchpad.IServiceUsage"/>
263 <require
264 permission="launchpad.Edit"
265- set_attributes="bug_reporting_guidelines
266- bug_reported_acknowledgement bugtracker
267- commercial_subscription description
268- development_focus displayname downloadurl
269- driver enable_bug_expiration
270- freshmeatproject homepage_content
271- homepageurl icon license_info licenses
272- logo mugshot official_answers
273- official_blueprints official_bug_tags
274- official_codehosting official_malone owner
275- programminglang project
276- redeemSubscriptionVoucher releaseroot
277- remote_product screenshotsurl
278- security_contact sourceforgeproject
279- summary title wikiurl"/>
280+ set_attributes="
281+ bug_reported_acknowledgement
282+ bug_reporting_guidelines
283+ bugtracker
284+ commercial_subscription
285+ description
286+ development_focus
287+ displayname
288+ downloadurl
289+ driver
290+ enable_bug_expiration
291+ freshmeatproject
292+ homepage_content
293+ homepageurl
294+ icon
295+ license_info
296+ licenses
297+ logo
298+ mugshot
299+ official_answers
300+ official_blueprints
301+ official_codehosting
302+ official_malone
303+ owner
304+ programminglang
305+ project
306+ redeemSubscriptionVoucher
307+ releaseroot
308+ remote_product
309+ screenshotsurl
310+ security_contact
311+ sourceforgeproject
312+ summary
313+ title
314+ wikiurl"/>
315+ <require
316+ permission="launchpad.BugSupervisor"
317+ set_attributes="official_bug_tags"/>
318
319 <!-- mark 2006-04-10 I put "name" in the admin group because
320 with Bazaar now in place, lots of people can have personal
321@@ -1438,12 +1461,27 @@
322 <require
323 permission="launchpad.Edit"
324 set_attributes="
325- displayname title summary description driver
326- members owner security_contact mirror_admin homepage_content
327- icon logo mugshot enable_bug_expiration
328- bug_reporting_guidelines bug_reported_acknowledgement
329- official_blueprints official_malone
330- official_rosetta official_answers official_bug_tags"/>
331+ bug_reported_acknowledgement
332+ bug_reporting_guidelines
333+ description
334+ displayname
335+ driver
336+ enable_bug_expiration
337+ homepage_content
338+ icon
339+ logo
340+ members
341+ mirror_admin
342+ mugshot
343+ official_answers
344+ official_blueprints
345+ official_bug_tags
346+ official_malone
347+ official_rosetta
348+ owner
349+ security_contact
350+ summary
351+ title"/>
352 <require
353 permission="launchpad.TranslationsAdmin"
354 set_attributes="