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
1=== modified file 'lib/lp/bugs/browser/tests/test_bugsupervisor.py'
2--- lib/lp/bugs/browser/tests/test_bugsupervisor.py 2010-05-25 20:36:49 +0000
3+++ lib/lp/bugs/browser/tests/test_bugsupervisor.py 2010-06-10 17:14:28 +0000
4@@ -1,4 +1,4 @@
5-# Copyright10 Canonical Ltd. This software is licensed under the
6+# Copyright 2010 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version (see the file LICENSE).
8
9 """Unit tests for bug supervisor views."""
10@@ -9,10 +9,14 @@
11
12 from zope.app.form.interfaces import ConversionError
13
14+import transaction
15+
16 from lp.bugs.browser.bugsupervisor import BugSupervisorEditSchema
17+from lp.registry.interfaces.person import PersonVisibility
18 from lp.testing import login, login_person, TestCaseWithFactory
19 from lp.testing.views import create_initialized_view
20 from canonical.testing import DatabaseFunctionalLayer
21+from canonical.launchpad.fields import PrivateMembershipTeamNotAllowed
22
23
24 class TestBugSupervisorEditView(TestCaseWithFactory):
25@@ -101,6 +105,33 @@
26 self.assertEqual([], view.errors)
27 self.assertEqual(self.team, self.product.bug_supervisor)
28
29+ def test_owner_appoint_his_private_team(self):
30+ private_team = self.factory.makeTeam(
31+ owner=self.owner,
32+ visibility=PersonVisibility.PRIVATE)
33+ form = self._makeForm(private_team)
34+ view = create_initialized_view(
35+ self.product, name='+bugsupervisor', form=form)
36+ self.assertEqual([], view.errors)
37+ self.assertEqual(private_team, self.product.bug_supervisor)
38+
39+ def test_owner_cannot_appoint_his_private_membership_team(self):
40+ private_membership_team = self.factory.makeTeam(
41+ owner=self.owner,
42+ visibility=PersonVisibility.PRIVATE_MEMBERSHIP)
43+ # Commit the transaction so the team will exist after the failed view
44+ # initialization calls abort.
45+ transaction.commit()
46+ login('admin@canonical.com')
47+ form = self._makeForm(private_membership_team)
48+ view = create_initialized_view(
49+ self.product, name='+bugsupervisor', form=form)
50+ self.assertTrue(
51+ type(view.errors[0].errors) is PrivateMembershipTeamNotAllowed)
52+ self.assertEqual("You must choose a valid person or team to be the "
53+ "bug supervisor for <boing />.",
54+ view.errors[1])
55+
56 def test_owner_cannot_appoint_another_team(self):
57 team = self.factory.makeTeam(name='smack', displayname='<smack />')
58 form = self._makeForm(team)
59@@ -162,6 +193,32 @@
60 self.assertEqual([], view.errors)
61 self.assertEqual(another_team, self.product.bug_supervisor)
62
63+ def test_admin_appoint_private_team(self):
64+ private_team = self.factory.makeTeam(
65+ visibility=PersonVisibility.PRIVATE)
66+ login('admin@canonical.com')
67+ form = self._makeForm(private_team)
68+ view = create_initialized_view(
69+ self.product, name='+bugsupervisor', form=form)
70+ self.assertEqual([], view.errors)
71+ self.assertEqual(private_team, self.product.bug_supervisor)
72+
73+ def test_admin_cannot_appoint_private_membership_team(self):
74+ private_membership_team = self.factory.makeTeam(
75+ visibility=PersonVisibility.PRIVATE_MEMBERSHIP)
76+ # Commit the transaction so the team will exist after the failed view
77+ # initialization calls abort.
78+ transaction.commit()
79+ login('admin@canonical.com')
80+ form = self._makeForm(private_membership_team)
81+ view = create_initialized_view(
82+ self.product, name='+bugsupervisor', form=form)
83+ self.assertTrue(
84+ type(view.errors[0].errors) is PrivateMembershipTeamNotAllowed)
85+ self.assertEqual("You must choose a valid person or team to be the "
86+ "bug supervisor for &lt;boing /&gt;.",
87+ view.errors[1])
88+
89
90 def test_suite():
91 return unittest.TestLoader().loadTestsFromName(__name__)
92
93=== modified file 'lib/lp/bugs/interfaces/bugsupervisor.py'
94--- lib/lp/bugs/interfaces/bugsupervisor.py 2010-04-29 15:32:46 +0000
95+++ lib/lp/bugs/interfaces/bugsupervisor.py 2010-06-10 17:14:28 +0000
96@@ -12,7 +12,7 @@
97 ]
98
99 from canonical.launchpad import _
100-from canonical.launchpad.fields import PublicPersonChoice
101+from canonical.launchpad.fields import ParticipatingPersonChoice
102
103 from zope.interface import Interface
104
105@@ -24,7 +24,7 @@
106
107 class IHasBugSupervisor(Interface):
108
109- bug_supervisor = exported(PublicPersonChoice(
110+ bug_supervisor = exported(ParticipatingPersonChoice(
111 title=_("Bug Supervisor"),
112 description=_(
113 "The person or team responsible for bug management."),
114@@ -37,5 +37,3 @@
115 @export_write_operation()
116 def setBugSupervisor(bug_supervisor, user):
117 """Set the bug contact and create a bug subscription."""
118-
119-