← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~deryck/launchpad/specification-sharing-policy-unused into lp:launchpad

 

Deryck Hodge has proposed merging lp:~deryck/launchpad/specification-sharing-policy-unused into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~deryck/launchpad/specification-sharing-policy-unused/+merge/124021

This branch adds specification_sharing_policy to Product. It's a first branch toward configuring sharing policy for blueprints. I'll admit my own TDD sins here and say that this is untested code, but I started this branch, trying to sort out how this all fit together. So this branch remains just the start of the sharing policy for blueprints. I will have separate branches for review to add a garbo job for populating specification_sharing_policy for existing projects and another that adds Product.getAllowedSpecificationInformationTypes and Production.getDefaultSpecificationInformationType. This last branch is where tests will live, to ensure the two methods that use SpecificationSharingPolicy return the correct information types.

There is no qa since this is unused code.

The branch is justified in terms of LOC because it's part of the disclosure project.
-- 
https://code.launchpad.net/~deryck/launchpad/specification-sharing-policy-unused/+merge/124021
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~deryck/launchpad/specification-sharing-policy-unused into lp:launchpad.
=== modified file 'lib/lp/blueprints/model/specification.py'
--- lib/lp/blueprints/model/specification.py	2012-09-11 14:06:21 +0000
+++ lib/lp/blueprints/model/specification.py	2012-09-12 18:22:22 +0000
@@ -9,6 +9,7 @@
     'recursive_blocked_query',
     'recursive_dependent_query',
     'Specification',
+    'SPECIFICATION_POLICY_ALLOWED_TYPES',
     'SpecificationSet',
     ]
 
@@ -74,10 +75,13 @@
 from lp.bugs.interfaces.bugtasksearch import BugTaskSearchParams
 from lp.bugs.model.buglinktarget import BugLinkTargetMixin
 from lp.registry.enums import (
+    FREE_INFORMATION_TYPES,
     InformationType,
+    NON_EMBARGOED_INFORMATION_TYPES,
     PRIVATE_INFORMATION_TYPES,
     PUBLIC_INFORMATION_TYPES,
     PUBLIC_PROPRIETARY_INFORMATION_TYPES,
+    SpecificationSharingPolicy,
     )
 from lp.registry.errors import CannotChangeInformationType
 from lp.registry.interfaces.distribution import IDistribution
@@ -128,6 +132,18 @@
         )""" % spec.id
 
 
+SPECIFICATION_POLICY_ALLOWED_TYPES = {
+    SpecificationSharingPolicy.PUBLIC: FREE_INFORMATION_TYPES,
+    SpecificationSharingPolicy.PUBLIC_OR_PROPRIETARY: (
+        NON_EMBARGOED_INFORMATION_TYPES),
+    SpecificationSharingPolicy.PROPRIETARY_OR_PUBLIC: (
+        NON_EMBARGOED_INFORMATION_TYPES),
+    SpecificationSharingPolicy.PROPRIETARY: [InformationType.PROPRIETARY],
+    SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY:
+        [InformationType.PROPRIETARY, InformationType.EMBARGOED],
+    }
+
+
 class Specification(SQLBase, BugLinkTargetMixin):
     """See ISpecification."""
 

=== modified file 'lib/lp/registry/enums.py'
--- lib/lp/registry/enums.py	2012-09-06 19:05:05 +0000
+++ lib/lp/registry/enums.py	2012-09-12 18:22:22 +0000
@@ -24,6 +24,7 @@
     'ProductJobType',
     'SECURITY_INFORMATION_TYPES',
     'SharingPermission',
+    'SpecificationSharingPolicy',
     'TeamMembershipPolicy',
     'TeamMembershipRenewalPolicy',
     ]
@@ -200,6 +201,44 @@
         """)
 
 
+class SpecificationSharingPolicy(DBEnumeratedType):
+
+    PUBLIC = DBItem(1, """
+        Public
+
+        Specifications are public.
+        """)
+
+    PUBLIC_OR_PROPRIETARY = DBItem(2, """
+        Public, can be proprietary
+
+        New specifications are public, but can be made proprietary later.
+        """)
+
+    PROPRIETARY_OR_PUBLIC = DBItem(3, """
+        Proprietary, can be public
+
+        New specifications are proprietary, but can be made public later. Only
+        people who can see the project's proprietary information can create
+        new specifications.
+        """)
+
+    PROPRIETARY = DBItem(4, """
+        Proprietary
+
+        Specifications are always proprietary. Only people who can see the
+        project's proprietary information can create new specifications.
+        """)
+
+    EMBARGOED_OR_PROPRIETARY = DBItem(5, """
+        Embargoed, can be proprietary
+
+        New specifications are embargoed, but can be made proprietary later.
+        Only people who can see the project's proprietary information can
+        create new specifications.
+        """)
+
+
 class TeamMembershipRenewalPolicy(DBEnumeratedType):
     """TeamMembership Renewal Policy.
 

=== modified file 'lib/lp/registry/interfaces/product.py'
--- lib/lp/registry/interfaces/product.py	2012-09-03 02:18:05 +0000
+++ lib/lp/registry/interfaces/product.py	2012-09-12 18:22:22 +0000
@@ -108,6 +108,7 @@
 from lp.registry.enums import (
     BranchSharingPolicy,
     BugSharingPolicy,
+    SpecificationSharingPolicy,
     )
 from lp.registry.interfaces.announcement import IMakesAnnouncements
 from lp.registry.interfaces.commercialsubscription import (
@@ -640,6 +641,11 @@
         description=_("Sharing policy for this project's bugs."),
         required=False, readonly=True, vocabulary=BugSharingPolicy),
         as_of='devel')
+    specification_sharing_policy = exported(Choice(
+        title=_('Specification sharing policy'),
+        description=_("Sharing policy for this project's specifications."),
+        required=False, readonly=True, vocabulary=SpecificationSharingPolicy),
+        as_of='devel')
 
     licenses = exported(
         Set(title=_('Licences'),
@@ -898,6 +904,18 @@
         Checks authorization and entitlement.
         """
 
+    @mutator_for(IProductPublic['specification_sharing_policy'])
+    @operation_parameters(
+        specification_sharing_policy=copy_field(
+            IProductPublic['specification_sharing_policy']))
+    @export_write_operation()
+    @operation_for_version("devel")
+    def setSpecificationSharingPolicy(specification_sharing_policy):
+        """Mutator for specification_sharing_policy.
+
+        Checks authorization and entitlement.
+        """
+
 
 class IProduct(
     IHasBugSupervisor, IProductEditRestricted,

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2012-09-06 00:01:38 +0000
+++ lib/lp/registry/model/product.py	2012-09-12 18:22:22 +0000
@@ -86,6 +86,7 @@
 from lp.blueprints.model.specification import (
     HasSpecificationsMixin,
     Specification,
+    SPECIFICATION_POLICY_ALLOWED_TYPES,
     )
 from lp.blueprints.model.sprint import HasSprintsMixin
 from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
@@ -122,6 +123,7 @@
     FREE_INFORMATION_TYPES,
     InformationType,
     PRIVATE_INFORMATION_TYPES,
+    SpecificationSharingPolicy,
     )
 from lp.registry.errors import CommercialSubscribersOnly
 from lp.registry.interfaces.accesspolicy import (
@@ -476,6 +478,8 @@
         enum=BugSharingPolicy, notNull=False, default=None)
     branch_sharing_policy = EnumCol(
         enum=BranchSharingPolicy, notNull=False, default=None)
+    specification_sharing_policy = EnumCol(
+        enum=SpecificationSharingPolicy, notNull=False, default=None)
     autoupdate = BoolCol(dbName='autoupdate', notNull=True, default=False)
     freshmeatproject = StringCol(notNull=False, default=None)
     sourceforgeproject = StringCol(notNull=False, default=None)
@@ -589,6 +593,14 @@
         self.bug_sharing_policy = bug_sharing_policy
         self._pruneUnusedPolicies()
 
+    def setSpecificationSharingPolicy(self, specification_sharing_policy):
+        """See `IProductEditRestricted`."""
+        self._prepare_to_set_sharing_policy(
+            specification_sharing_policy, SpecificationSharingPolicy,
+            'specifications', SPECIFICATION_POLICY_ALLOWED_TYPES)
+        self.specification_sharing_policy = specification_sharing_policy
+        self._pruneUnusedPolicies()
+
     def getAllowedBugInformationTypes(self):
         """See `IProduct.`"""
         if self.bug_sharing_policy is not None:


Follow ups