Merge lp:~stevenk/launchpad/notification-already-targetted into lp:launchpad

Proposed by Steve Kowalik on 2012-01-24
Status: Merged
Approved by: Steve Kowalik on 2012-01-24
Approved revision: no longer in the source branch.
Merged at revision: 14719
Proposed branch: lp:~stevenk/launchpad/notification-already-targetted
Merge into: lp:launchpad
Diff against target: 61 lines (+24/-6)
2 files modified
lib/lp/bugs/browser/bugnomination.py (+4/-5)
lib/lp/bugs/browser/tests/test_bugnomination.py (+20/-1)
To merge this branch: bzr merge lp:~stevenk/launchpad/notification-already-targetted
Reviewer Review Type Date Requested Status
William Grant code 2012-01-24 Approve on 2012-01-24
Review via email: mp+89826@code.launchpad.net

Commit Message

[r=wgrant][bug=907840] Workaround lack of ISourcePackage security adapters in BugNominationView by using IBugTask.userHas{Driver,BugSupervisor}Privileges().

Description of the Change

This branch is badly named, but it solves the bug where a distribution source package targetted bug has been nominated to a series and then a user attempts to +nominate using the series task. BugNominationView.userIsBugSupervisor() was checking the target only and ignoring the distribution-wide rules. As such, I have ripped out the check_permission() calls and replaced them with IBugTask.userHas{Driver,BugSupervisor}Privileges() calls.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugnomination.py'
2--- lib/lp/bugs/browser/bugnomination.py 2012-01-01 02:58:52 +0000
3+++ lib/lp/bugs/browser/bugnomination.py 2012-01-24 05:19:24 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Browser view classes related to bug nominations."""
10@@ -90,13 +90,12 @@
11
12 def userIsReleaseManager(self):
13 """Does the current user have release management privileges?"""
14- return check_permission(
15- "launchpad.Driver", self.current_bugtask.target)
16+ return self.current_bugtask.userHasDriverPrivileges(self.user)
17
18 def userIsBugSupervisor(self):
19 """Is the current user the bug supervisor?"""
20- return check_permission(
21- "launchpad.BugSupervisor", self.current_bugtask.target)
22+ return self.current_bugtask.userHasBugSupervisorPrivileges(
23+ self.user)
24
25 def userCanChangeDriver(self):
26 """Can the current user set the release management team?"""
27
28=== modified file 'lib/lp/bugs/browser/tests/test_bugnomination.py'
29--- lib/lp/bugs/browser/tests/test_bugnomination.py 2012-01-15 13:32:27 +0000
30+++ lib/lp/bugs/browser/tests/test_bugnomination.py 2012-01-24 05:19:24 +0000
31@@ -1,4 +1,4 @@
32-# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
33+# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
34 # GNU Affero General Public License version 3 (see the file LICENSE).
35
36 """Tests for bug nomination views."""
37@@ -145,6 +145,25 @@
38 view = create_initialized_view(series_bugtask, name='+nominate')
39 self.assertEqual(0, len(view.request.notifications))
40
41+ def test_series_targets_allow_nomination(self):
42+ # When a bug is already nominated for a series, the view checks
43+ # for bug supervisor permission on the series correctly.
44+ person = self.factory.makePerson()
45+ dsp = self.factory.makeDistributionSourcePackage()
46+ series = self.factory.makeDistroSeries(distribution=dsp.distribution)
47+ self._makeBugSupervisorTeam(
48+ person, dsp.distribution.owner, dsp.distribution)
49+ bug = self.factory.makeBug(
50+ distribution=dsp.distribution,
51+ sourcepackagename=dsp.sourcepackagename)
52+ with person_logged_in(dsp.distribution.owner):
53+ nomination = bug.addNomination(dsp.distribution.owner, series)
54+ nomination.approve(person)
55+ series_bugtask = bug.bugtasks[1]
56+ with person_logged_in(person):
57+ view = create_initialized_view(series_bugtask, name='+nominate')
58+ self.assertEqual(0, len(view.request.notifications))
59+
60
61 class TestBugEditLinks(TestCaseWithFactory):
62