launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05334
[Merge] lp:~stevenk/launchpad/hide-create-new-ppa-open-team into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/hide-create-new-ppa-open-team into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #784596 in Launchpad itself: "UI implies open/delegated teams can have PPAs"
https://bugs.launchpad.net/launchpad/+bug/784596
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/hide-create-new-ppa-open-team/+merge/80650
Hide the 'Create a new PPA' link in the UI if the team is not moderated or restricted.
This should also fix up create_initialized_view() to create better URLs in its test request. Drive-by some excess whitespace.
--
https://code.launchpad.net/~stevenk/launchpad/hide-create-new-ppa-open-team/+merge/80650
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/hide-create-new-ppa-open-team into lp:launchpad.
=== added file 'lib/lp/registry/browser/tests/test_team_activate_ppa.py'
--- lib/lp/registry/browser/tests/test_team_activate_ppa.py 1970-01-01 00:00:00 +0000
+++ lib/lp/registry/browser/tests/test_team_activate_ppa.py 2011-10-28 05:40:31 +0000
@@ -0,0 +1,41 @@
+# Copyright 2011 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+__metaclass__ = type
+
+from canonical.testing.layers import DatabaseFunctionalLayer
+from lp.registry.interfaces.person import TeamSubscriptionPolicy
+from lp.testing import (
+ person_logged_in,
+ TestCaseWithFactory,
+ )
+from lp.testing.views import create_initialized_view
+
+
+class TestTeamActivatePPA(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_moderated_team_has_link(self):
+ # Moderated teams have a link to create a new PPA.
+ team = self.factory.makeTeam(
+ subscription_policy=TeamSubscriptionPolicy.MODERATED)
+ with person_logged_in(team.teamowner):
+ view = create_initialized_view(
+ team, '+index', principal=team.teamowner)
+ html = view()
+ self.assertTrue('Create a new PPA' in html)
+ self.assertFalse(
+ 'Open or Delegated teams can not create PPAs.' in html)
+
+ def test_open_team_does_not_have_link(self):
+ # Open teams do not have a link to create a new PPA.
+ team = self.factory.makeTeam(
+ subscription_policy=TeamSubscriptionPolicy.OPEN)
+ with person_logged_in(team.teamowner):
+ view = create_initialized_view(
+ team, '+index', principal=team.teamowner)
+ html = view()
+ self.assertFalse('Create a new PPA' in html)
+ self.assertTrue(
+ 'Open or Delegated teams can not create PPAs.' in html)
=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py 2011-10-25 23:20:14 +0000
+++ lib/lp/registry/interfaces/person.py 2011-10-28 05:40:31 +0000
@@ -1468,6 +1468,12 @@
allowed.
"""
+ def canCreatePPA():
+ """Check if a person or team can create a PPA.
+
+ :return: a boolean.
+ """
+
class IPersonViewRestricted(Interface):
"""IPerson attributes that require launchpad.View permission."""
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2011-10-04 07:42:19 +0000
+++ lib/lp/registry/model/person.py 2011-10-28 05:40:31 +0000
@@ -228,6 +228,7 @@
MailingListAutoSubscribePolicy,
)
from lp.registry.interfaces.person import (
+ CLOSED_TEAM_POLICY,
ImmutableVisibilityError,
IPerson,
IPersonSet,
@@ -2911,6 +2912,10 @@
else:
return None
+ def canCreatePPA(self):
+ """See `IPerson.`"""
+ return self.subscriptionpolicy in CLOSED_TEAM_POLICY
+
class PersonSet:
"""The set of persons."""
=== modified file 'lib/lp/services/openid/browser/openiddiscovery.py'
--- lib/lp/services/openid/browser/openiddiscovery.py 2010-08-24 10:45:57 +0000
+++ lib/lp/services/openid/browser/openiddiscovery.py 2011-10-28 05:40:31 +0000
@@ -78,5 +78,3 @@
def openid_server_url(self):
"""The OpenID Server endpoint URL for Launchpad."""
return CurrentOpenIDEndPoint.getServiceURL()
-
-
=== modified file 'lib/lp/soyuz/templates/person-portlet-ppas.pt'
--- lib/lp/soyuz/templates/person-portlet-ppas.pt 2010-10-26 10:32:35 +0000
+++ lib/lp/soyuz/templates/person-portlet-ppas.pt 2011-10-28 05:40:31 +0000
@@ -9,9 +9,18 @@
<div tal:replace="structure context/@@+ppas-list"/>
<ul class="horizontal">
- <li tal:define="link context/menu:overview/activate_ppa"
- tal:condition="link/enabled"
- tal:content="structure link/fmt:icon-link" />
+ <tal:can-create-ppa condition="context/canCreatePPA">
+ <li tal:define="link context/menu:overview/activate_ppa"
+ tal:condition="link/enabled"
+ tal:content="structure link/fmt:icon-link" />
+ </tal:can-create-ppa>
+ <tal:cannot-create-ppa condition="not: context/canCreatePPA">
+ <span>
+ <span class="security sprite"></span>
+ Open or Delegated teams can not create PPAs.
+ <a href="+edit" class="edit sprite"></a>
+ </span>
+ </tal:cannot-create-ppa>
<tal:is-person condition="not: context/is_team">
<li tal:define="link context/menu:overview/view_ppa_subscriptions"
=== modified file 'lib/lp/testing/views.py'
--- lib/lp/testing/views.py 2011-09-20 22:33:07 +0000
+++ lib/lp/testing/views.py 2011-10-28 05:40:31 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Functions to help with the testing of views."""
@@ -24,7 +24,10 @@
ICanonicalUrlData,
IPlacelessAuthUtility,
)
-from canonical.launchpad.webapp.publisher import layer_for_rootsite
+from canonical.launchpad.webapp.publisher import (
+ canonical_url,
+ layer_for_rootsite,
+ )
from canonical.launchpad.webapp.servers import LaunchpadTestRequest
@@ -89,6 +92,9 @@
method = 'GET'
else:
method = 'POST'
+ if not server_url:
+ server_url = canonical_url(context)
+ path_info = ''
view = create_view(
context, name, form, layer, server_url, method, principal,
query_string, cookie, request, path_info, rootsite=rootsite,