launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06204
[Merge] lp:~sinzui/launchpad/administer-team into lp:launchpad
Curtis Hovey has proposed merging lp:~sinzui/launchpad/administer-team into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #669658 in Launchpad itself: "~registry cannot rename team"
https://bugs.launchpad.net/launchpad/+bug/669658
For more details, see:
https://code.launchpad.net/~sinzui/launchpad/administer-team/+merge/90530
--
https://code.launchpad.net/~sinzui/launchpad/administer-team/+merge/90530
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/administer-team into lp:launchpad.
=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py 2012-01-25 04:56:50 +0000
+++ lib/lp/registry/browser/team.py 2012-01-27 21:00:28 +0000
@@ -131,6 +131,7 @@
TeamSubscriptionPolicy,
)
from lp.registry.interfaces.poll import IPollSet
+from lp.registry.interfaces.role import IPersonRoles
from lp.registry.interfaces.teammembership import (
CyclicalTeamMembershipError,
DAYS_BEFORE_EXPIRATION_WARNING_IS_SENT,
@@ -138,6 +139,7 @@
ITeamMembershipSet,
TeamMembershipStatus,
)
+from lp.security import ModerateByRegistryExpertsOrAdmins
from lp.services.config import config
from lp.services.fields import PublicPersonChoice
from lp.services.identity.interfaces.emailaddress import IEmailAddressSet
@@ -1529,6 +1531,20 @@
summary = 'Change the owner of the team'
return Link(target, text, summary, icon='edit')
+ def administer(self):
+ target = '+review'
+ text = 'Administer'
+ # Team owners and admins have launchpad.Moderate on ITeam, but we
+ # do not want them to see this link because it is for Lp admins
+ # and registry experts.
+ checker = ModerateByRegistryExpertsOrAdmins(self)
+ if checker.checkAuthenticated(IPersonRoles(self.user)):
+ enabled = True
+ else:
+ enabled = False
+ summary = 'Administer this team on behalf of a user'
+ return Link(target, text, summary, icon='edit', enabled=enabled)
+
@enabled_with_permission('launchpad.Moderate')
def delete(self):
target = '+delete'
@@ -2174,7 +2190,7 @@
usedfor = ITeamIndexMenu
facet = 'overview'
title = 'Change team'
- links = ('edit', 'delete', 'join', 'add_my_teams', 'leave')
+ links = ('edit', 'administer', 'delete', 'join', 'add_my_teams', 'leave')
class TeamEditMenu(TeamNavigationMenuBase):
=== modified file 'lib/lp/registry/browser/tests/test_team.py'
--- lib/lp/registry/browser/tests/test_team.py 2012-01-23 18:15:34 +0000
+++ lib/lp/registry/browser/tests/test_team.py 2012-01-27 21:00:28 +0000
@@ -10,7 +10,10 @@
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
-from lp.registry.browser.team import TeamOverviewMenu
+from lp.registry.browser.team import (
+ TeamIndexMenu,
+ TeamOverviewMenu,
+ )
from lp.registry.interfaces.mailinglist import MailingListStatus
from lp.registry.interfaces.person import (
CLOSED_TEAM_POLICY,
@@ -30,6 +33,7 @@
from lp.services.webapp.publisher import canonical_url
from lp.soyuz.enums import ArchiveStatus
from lp.testing import (
+ login_celebrity,
login_person,
person_logged_in,
TestCaseWithFactory,
@@ -445,6 +449,37 @@
super(TestTeamMenu, self).setUp()
self.team = self.factory.makeTeam()
+ def test_TeamIndexMenu(self):
+ view = create_view(self.team, '+index')
+ menu = TeamIndexMenu(view)
+ self.assertEqual(
+ ('edit', 'administer', 'delete', 'join', 'add_my_teams', 'leave'),
+ menu.links)
+
+ def test_TeamIndexMenu_owner(self):
+ login_person(self.team.teamowner)
+ view = create_view(self.team, '+index')
+ menu = TeamIndexMenu(view)
+ self.assertEqual(
+ ['edit', 'delete', 'add_my_teams'],
+ [link.name for link in menu.iterlinks() if link.enabled])
+
+ def test_TeamIndexMenu_admin(self):
+ login_celebrity('admin')
+ view = create_view(self.team, '+index')
+ menu = TeamIndexMenu(view)
+ self.assertEqual(
+ ['edit', 'administer', 'delete', 'join', 'add_my_teams'],
+ [link.name for link in menu.iterlinks() if link.enabled])
+
+ def test_TeamIndexMenu_registry_experts(self):
+ login_celebrity('registry_experts')
+ view = create_view(self.team, '+index')
+ menu = TeamIndexMenu(view)
+ self.assertEqual(
+ ['administer', 'delete', 'join', 'add_my_teams'],
+ [link.name for link in menu.iterlinks() if link.enabled])
+
def test_TeamOverviewMenu_check_menu_links_without_mailing(self):
menu = TeamOverviewMenu(self.team)
# Remove moderate_mailing_list because it asserts that there is
@@ -452,7 +487,7 @@
no_mailinst_list_links = [
link for link in menu.links if link != 'moderate_mailing_list']
menu.links = no_mailinst_list_links
- self.assertEqual(True, check_menu_links(menu))
+ self.assertIs(True, check_menu_links(menu))
link = menu.configure_mailing_list()
self.assertEqual('Create a mailing list', link.text)
@@ -460,7 +495,7 @@
self.factory.makeMailingList(
self.team, self.team.teamowner)
menu = TeamOverviewMenu(self.team)
- self.assertEqual(True, check_menu_links(menu))
+ self.assertIs(True, check_menu_links(menu))
link = menu.configure_mailing_list()
self.assertEqual('Configure mailing list', link.text)
=== modified file 'lib/lp/testing/menu.py'
--- lib/lp/testing/menu.py 2011-12-30 09:16:36 +0000
+++ lib/lp/testing/menu.py 2012-01-27 21:00:28 +0000
@@ -37,7 +37,11 @@
try:
canonical_url(context, view_name=view_name, rootsite=link.site)
except Exception:
- return 'Bad link %s: %s' % (link.name, canonical_url(context))
+ try:
+ url = canonical_url(context)
+ except Exception:
+ url = repr(context)
+ return 'Bad link %s: %s' % (link.name, url)
return True
Follow ups