launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08674
[Merge] lp:~jml/launchpad/p3a-private-team into lp:launchpad
Jonathan Lange has proposed merging lp:~jml/launchpad/p3a-private-team into lp:launchpad with lp:~jml/launchpad/validate-ppa-owner as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jml/launchpad/p3a-private-team/+merge/109600
IPerson.createPPA allows creating PPAs via the API. At the moment, it's impossible to use it to create a private PPA for a private team, despite the fact that Launchpad's web UI allows you to do just that.
This branch brings createPPA up-to-date, and changes the browser code to go via createPPA.
--
https://code.launchpad.net/~jml/launchpad/p3a-private-team/+merge/109600
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jml/launchpad/p3a-private-team into lp:launchpad.
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2012-06-11 10:30:46 +0000
+++ lib/lp/registry/model/person.py 2012-06-11 10:30:46 +0000
@@ -2981,6 +2981,9 @@
errors = validate_ppa(self, name, private)
if errors:
raise PPACreationError(errors)
+ # XXX cprov 2009-03-27 bug=188564: We currently only create PPAs
+ # for Ubuntu distribution. PPA creation should be revisited when we
+ # start supporting other distribution (debian, mainly).
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
return getUtility(IArchiveSet).new(
owner=self, purpose=ArchivePurpose.PPA,
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2012-06-11 10:30:46 +0000
+++ lib/lp/soyuz/browser/archive.py 2012-06-11 10:30:46 +0000
@@ -1988,21 +1988,13 @@
@action(_("Activate"), name="activate")
def save_action(self, action, data):
"""Activate a PPA and moves to its page."""
-
# 'name' field is omitted from the form data for default PPAs and
# it's dealt with by IArchive.new(), which will use the default
# PPA name.
name = data.get('name', None)
-
- # XXX: jml: I think this ought to call createPPA.
- # XXX cprov 2009-03-27 bug=188564: We currently only create PPAs
- # for Ubuntu distribution. PPA creation should be revisited when we
- # start supporting other distribution (debian, mainly).
- ppa = getUtility(IArchiveSet).new(
- owner=self.context, purpose=ArchivePurpose.PPA,
- distribution=self.ubuntu, name=name,
- displayname=data['displayname'], description=data['description'])
-
+ displayname = data['displayname']
+ description = data['description']
+ ppa = self.context.createPPA(name, displayname, description)
self.next_url = canonical_url(ppa)
@property
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2012-06-11 10:30:46 +0000
+++ lib/lp/soyuz/model/archive.py 2012-06-11 10:30:46 +0000
@@ -2071,8 +2071,10 @@
# which determines who is granted launchpad.Commercial
# permissions.
role = IPersonRoles(creator)
- if not (role.in_admin or role.in_commercial_admin):
+ if not (owner.private or role.in_admin or role.in_commercial_admin):
return '%s is not allowed to make private PPAs' % creator.name
+ elif owner.private:
+ return 'Private teams may not have public archives.'
if owner.is_team and (
owner.subscriptionpolicy in OPEN_TEAM_POLICY):
return "Open teams cannot have PPAs."
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2012-06-11 10:30:46 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2012-06-11 10:30:46 +0000
@@ -26,10 +26,12 @@
from lp.buildmaster.enums import BuildStatus
from lp.registry.interfaces.person import (
IPersonSet,
+ PersonVisibility,
TeamSubscriptionPolicy,
)
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.interfaces.series import SeriesStatus
+from lp.registry.interfaces.teammembership import TeamMembershipStatus
from lp.services.database.sqlbase import sqlvalues
from lp.services.features.testing import FeatureFixture
from lp.services.job.interfaces.job import JobStatus
@@ -1708,6 +1710,36 @@
ppa_owner = self.factory.makePerson()
self.assertIsNone(validate_ppa(ppa_owner, None))
+ def test_private_team_private_ppa(self):
+ # Folk with launchpad.Edit on a private team can make private PPAs for
+ # that team, regardless of whether they have super-powers.a
+ team_owner = self.factory.makePerson()
+ private_team = self.factory.makeTeam(
+ owner=team_owner, visibility=PersonVisibility.PRIVATE,
+ subscription_policy=TeamSubscriptionPolicy.RESTRICTED)
+ team_admin = self.factory.makePerson()
+ with person_logged_in(team_owner):
+ private_team.addMember(
+ team_admin, team_owner, status=TeamMembershipStatus.ADMIN)
+ with person_logged_in(team_admin):
+ result = validate_ppa(private_team, 'ppa', private=True)
+ self.assertIsNone(result)
+
+ def test_private_team_public_ppa(self):
+ # No one can make a public PPA for a private team.
+ team_owner = self.factory.makePerson()
+ private_team = self.factory.makeTeam(
+ owner=team_owner, visibility=PersonVisibility.PRIVATE,
+ subscription_policy=TeamSubscriptionPolicy.RESTRICTED)
+ team_admin = self.factory.makePerson()
+ with person_logged_in(team_owner):
+ private_team.addMember(
+ team_admin, team_owner, status=TeamMembershipStatus.ADMIN)
+ with person_logged_in(team_admin):
+ result = validate_ppa(private_team, 'ppa', private=False)
+ self.assertEqual(
+ 'Private teams may not have public archives.', result)
+
class TestGetComponentsForSeries(TestCaseWithFactory):
"""Tests for Archive.getComponentsForSeries."""
=== modified file 'lib/lp/soyuz/tests/test_person_createppa.py'
--- lib/lp/soyuz/tests/test_person_createppa.py 2012-06-11 10:30:46 +0000
+++ lib/lp/soyuz/tests/test_person_createppa.py 2012-06-11 10:30:46 +0000
@@ -7,6 +7,11 @@
from zope.security.interfaces import Unauthorized
from lp.registry.errors import PPACreationError
+from lp.registry.interfaces.person import (
+ PersonVisibility,
+ TeamSubscriptionPolicy,
+ )
+from lp.registry.interfaces.teammembership import TeamMembershipStatus
from lp.testing import (
celebrity_logged_in,
person_logged_in,
@@ -49,3 +54,16 @@
with person_logged_in(person):
ppa = person.createPPA(suppress_subscription_notifications=True)
self.assertEqual(True, ppa.suppress_subscription_notifications)
+
+ def test_private_team_private_ppa(self):
+ team_owner = self.factory.makePerson()
+ private_team = self.factory.makeTeam(
+ owner=team_owner, visibility=PersonVisibility.PRIVATE,
+ subscription_policy=TeamSubscriptionPolicy.RESTRICTED)
+ team_admin = self.factory.makePerson()
+ with person_logged_in(team_owner):
+ private_team.addMember(
+ team_admin, team_owner, status=TeamMembershipStatus.ADMIN)
+ with person_logged_in(team_admin):
+ ppa = private_team.createPPA(private=True)
+ self.assertEqual(True, ppa.private)
Follow ups