Merge lp:~bac/launchpad/bug-591345 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 10994
Proposed branch: lp:~bac/launchpad/bug-591345
Merge into: lp:launchpad
Diff against target: 119 lines (+60/-5)
2 files modified
lib/lp/bugs/browser/tests/test_bugsupervisor.py (+58/-1)
lib/lp/bugs/interfaces/bugsupervisor.py (+2/-4)
To merge this branch: bzr merge lp:~bac/launchpad/bug-591345
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+27084@code.launchpad.net

Commit message

Allow private teams to be set as bug supervisor in the web interface.

Description of the change

= Summary =

A private team should be allowed to be a bug supervisor but due to a
regression in the interface private teams are not allowed.

== Proposed fix ==

Change the widget to be a ParticipatingPersonChoice.

== Pre-implementation notes ==

Chat with Curtis.

== Implementation details ==

As above.

== Tests ==

bin/test -vvm lp.bugs -t test_bugsupervisor

== Demo and Q/A ==

Create a private team and assign it as a bug supervisor to a project you
own.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/bugs/browser/tests/test_bugsupervisor.py
  lib/lp/bugs/interfaces/bugsupervisor.py

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

This is great. Thanks for getting this fixed at short notice.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/browser/tests/test_bugsupervisor.py'
--- lib/lp/bugs/browser/tests/test_bugsupervisor.py 2010-05-25 20:36:49 +0000
+++ lib/lp/bugs/browser/tests/test_bugsupervisor.py 2010-06-10 17:14:28 +0000
@@ -1,4 +1,4 @@
1# Copyright10 Canonical Ltd. This software is licensed under the1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version (see the file LICENSE).2# GNU Affero General Public License version (see the file LICENSE).
33
4"""Unit tests for bug supervisor views."""4"""Unit tests for bug supervisor views."""
@@ -9,10 +9,14 @@
99
10from zope.app.form.interfaces import ConversionError10from zope.app.form.interfaces import ConversionError
1111
12import transaction
13
12from lp.bugs.browser.bugsupervisor import BugSupervisorEditSchema14from lp.bugs.browser.bugsupervisor import BugSupervisorEditSchema
15from lp.registry.interfaces.person import PersonVisibility
13from lp.testing import login, login_person, TestCaseWithFactory16from lp.testing import login, login_person, TestCaseWithFactory
14from lp.testing.views import create_initialized_view17from lp.testing.views import create_initialized_view
15from canonical.testing import DatabaseFunctionalLayer18from canonical.testing import DatabaseFunctionalLayer
19from canonical.launchpad.fields import PrivateMembershipTeamNotAllowed
1620
1721
18class TestBugSupervisorEditView(TestCaseWithFactory):22class TestBugSupervisorEditView(TestCaseWithFactory):
@@ -101,6 +105,33 @@
101 self.assertEqual([], view.errors)105 self.assertEqual([], view.errors)
102 self.assertEqual(self.team, self.product.bug_supervisor)106 self.assertEqual(self.team, self.product.bug_supervisor)
103107
108 def test_owner_appoint_his_private_team(self):
109 private_team = self.factory.makeTeam(
110 owner=self.owner,
111 visibility=PersonVisibility.PRIVATE)
112 form = self._makeForm(private_team)
113 view = create_initialized_view(
114 self.product, name='+bugsupervisor', form=form)
115 self.assertEqual([], view.errors)
116 self.assertEqual(private_team, self.product.bug_supervisor)
117
118 def test_owner_cannot_appoint_his_private_membership_team(self):
119 private_membership_team = self.factory.makeTeam(
120 owner=self.owner,
121 visibility=PersonVisibility.PRIVATE_MEMBERSHIP)
122 # Commit the transaction so the team will exist after the failed view
123 # initialization calls abort.
124 transaction.commit()
125 login('admin@canonical.com')
126 form = self._makeForm(private_membership_team)
127 view = create_initialized_view(
128 self.product, name='+bugsupervisor', form=form)
129 self.assertTrue(
130 type(view.errors[0].errors) is PrivateMembershipTeamNotAllowed)
131 self.assertEqual("You must choose a valid person or team to be the "
132 "bug supervisor for <boing />.",
133 view.errors[1])
134
104 def test_owner_cannot_appoint_another_team(self):135 def test_owner_cannot_appoint_another_team(self):
105 team = self.factory.makeTeam(name='smack', displayname='<smack />')136 team = self.factory.makeTeam(name='smack', displayname='<smack />')
106 form = self._makeForm(team)137 form = self._makeForm(team)
@@ -162,6 +193,32 @@
162 self.assertEqual([], view.errors)193 self.assertEqual([], view.errors)
163 self.assertEqual(another_team, self.product.bug_supervisor)194 self.assertEqual(another_team, self.product.bug_supervisor)
164195
196 def test_admin_appoint_private_team(self):
197 private_team = self.factory.makeTeam(
198 visibility=PersonVisibility.PRIVATE)
199 login('admin@canonical.com')
200 form = self._makeForm(private_team)
201 view = create_initialized_view(
202 self.product, name='+bugsupervisor', form=form)
203 self.assertEqual([], view.errors)
204 self.assertEqual(private_team, self.product.bug_supervisor)
205
206 def test_admin_cannot_appoint_private_membership_team(self):
207 private_membership_team = self.factory.makeTeam(
208 visibility=PersonVisibility.PRIVATE_MEMBERSHIP)
209 # Commit the transaction so the team will exist after the failed view
210 # initialization calls abort.
211 transaction.commit()
212 login('admin@canonical.com')
213 form = self._makeForm(private_membership_team)
214 view = create_initialized_view(
215 self.product, name='+bugsupervisor', form=form)
216 self.assertTrue(
217 type(view.errors[0].errors) is PrivateMembershipTeamNotAllowed)
218 self.assertEqual("You must choose a valid person or team to be the "
219 "bug supervisor for &lt;boing /&gt;.",
220 view.errors[1])
221
165222
166def test_suite():223def test_suite():
167 return unittest.TestLoader().loadTestsFromName(__name__)224 return unittest.TestLoader().loadTestsFromName(__name__)
168225
=== modified file 'lib/lp/bugs/interfaces/bugsupervisor.py'
--- lib/lp/bugs/interfaces/bugsupervisor.py 2010-04-29 15:32:46 +0000
+++ lib/lp/bugs/interfaces/bugsupervisor.py 2010-06-10 17:14:28 +0000
@@ -12,7 +12,7 @@
12 ]12 ]
1313
14from canonical.launchpad import _14from canonical.launchpad import _
15from canonical.launchpad.fields import PublicPersonChoice15from canonical.launchpad.fields import ParticipatingPersonChoice
1616
17from zope.interface import Interface17from zope.interface import Interface
1818
@@ -24,7 +24,7 @@
2424
25class IHasBugSupervisor(Interface):25class IHasBugSupervisor(Interface):
2626
27 bug_supervisor = exported(PublicPersonChoice(27 bug_supervisor = exported(ParticipatingPersonChoice(
28 title=_("Bug Supervisor"),28 title=_("Bug Supervisor"),
29 description=_(29 description=_(
30 "The person or team responsible for bug management."),30 "The person or team responsible for bug management."),
@@ -37,5 +37,3 @@
37 @export_write_operation()37 @export_write_operation()
38 def setBugSupervisor(bug_supervisor, user):38 def setBugSupervisor(bug_supervisor, user):
39 """Set the bug contact and create a bug subscription."""39 """Set the bug contact and create a bug subscription."""
40
41