launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06615
[Merge] lp:~stevenk/launchpad/product-distribution-accesspolicy into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/product-distribution-accesspolicy into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/product-distribution-accesspolicy/+merge/96499
Create default accesspolicies on creation of a new product or distribution.
--
https://code.launchpad.net/~stevenk/launchpad/product-distribution-accesspolicy/+merge/96499
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/product-distribution-accesspolicy into lp:launchpad.
=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py 2012-02-08 06:00:46 +0000
+++ lib/lp/registry/model/distribution.py 2012-03-08 01:14:18 +0000
@@ -27,7 +27,6 @@
from storm.locals import (
And,
Desc,
- Int,
Join,
Max,
Or,
@@ -97,7 +96,9 @@
from lp.code.interfaces.seriessourcepackagebranch import (
IFindOfficialBranchLinks,
)
+from lp.registry.enums import InformationType
from lp.registry.errors import NoSuchDistroSeries
+from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.distribution import (
IBaseDistribution,
IDerivativeDistribution,
@@ -1764,6 +1765,10 @@
icon=icon)
getUtility(IArchiveSet).new(distribution=distro,
owner=owner, purpose=ArchivePurpose.PRIMARY)
+ policies = itertools.product(
+ (distro,), (InformationType.USERDATA,
+ InformationType.EMBARGOEDSECURITY))
+ getUtility(IAccessPolicySource).create(policies)
return distro
def getCurrentSourceReleases(self, distro_source_packagenames):
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2012-02-14 07:06:37 +0000
+++ lib/lp/registry/model/product.py 2012-03-08 01:14:18 +0000
@@ -15,6 +15,7 @@
import calendar
import datetime
import httplib
+import itertools
import operator
from lazr.delegates import delegates
@@ -37,7 +38,6 @@
from storm.locals import (
And,
Desc,
- Int,
Join,
Not,
Or,
@@ -115,7 +115,9 @@
)
from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
from lp.code.model.sourcepackagerecipedata import SourcePackageRecipeData
+from lp.registry.enums import InformationType
from lp.registry.errors import CommercialSubscribersOnly
+from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
from lp.registry.interfaces.person import (
IPersonSet,
@@ -1490,6 +1492,12 @@
'called MAIN or HEAD.'))
product.development_focus = trunk
+ # Add default AccessPolicies.
+ policies = itertools.product(
+ (product,), (InformationType.USERDATA,
+ InformationType.EMBARGOEDSECURITY))
+ getUtility(IAccessPolicySource).create(policies)
+
return product
def forReview(self, search_text=None, active=None,
=== modified file 'lib/lp/registry/tests/test_distribution.py'
--- lib/lp/registry/tests/test_distribution.py 2012-01-25 04:01:19 +0000
+++ lib/lp/registry/tests/test_distribution.py 2012-03-08 01:14:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for Distribution."""
@@ -25,10 +25,12 @@
from lp.app.enums import ServiceUsage
from lp.app.errors import NotFoundError
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+from lp.registry.enums import InformationType
from lp.registry.errors import (
NoSuchDistroSeries,
OpenTeamLinkageError,
)
+from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.distribution import (
IDistribution,
IDistributionSet,
@@ -265,6 +267,14 @@
provides_all = MatchesAll(*map(Provides, expected_interfaces))
self.assertThat(distro, provides_all)
+ def test_distribution_creation_creates_accesspolicies(self):
+ # Creating a new distribution also creates AccessPolicies for it.
+ distro = self.factory.makeDistribution()
+ ap = getUtility(IAccessPolicySource).findByPillar((distro,))
+ expected = [
+ InformationType.USERDATA, InformationType.EMBARGOEDSECURITY]
+ self.assertContentEqual(expected, [policy.type for policy in ap])
+
class TestDistributionCurrentSourceReleases(
TestDistroSeriesCurrentSourceReleases):
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2012-02-28 05:36:01 +0000
+++ lib/lp/registry/tests/test_product.py 2012-03-08 01:14:18 +0000
@@ -10,6 +10,7 @@
import pytz
from testtools.matchers import MatchesAll
import transaction
+from zope.component import getUtility
from zope.security.interfaces import Unauthorized
from zope.security.proxy import removeSecurityProxy
@@ -24,10 +25,12 @@
)
from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
from lp.bugs.interfaces.bugsupervisor import IHasBugSupervisor
+from lp.registry.enums import InformationType
from lp.registry.errors import (
CommercialSubscribersOnly,
OpenTeamLinkageError,
)
+from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
from lp.registry.interfaces.person import (
CLOSED_TEAM_POLICY,
@@ -342,6 +345,14 @@
product.setPrivateBugs(True, bug_supervisor)
self.assertTrue(product.private_bugs)
+ def test_product_creation_creates_accesspolicies(self):
+ # Creating a new product also creates AccessPolicies for it.
+ product = self.factory.makeProduct()
+ ap = getUtility(IAccessPolicySource).findByPillar((product,))
+ expected = [
+ InformationType.USERDATA, InformationType.EMBARGOEDSECURITY]
+ self.assertContentEqual(expected, [policy.type for policy in ap])
+
class TestProductFiles(TestCase):
"""Tests for downloadable product files."""