← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/fix-banner into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/fix-banner into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~abentley/launchpad/fix-banner/+merge/124052

= Summary =
The privacy banner shows for Specification pages, but only +index describes information type.

== Proposed fix ==
Make all views that have Specification as their context work.

== Pre-implementation notes ==
None

== LOC Rationale ==
Part of private projects

== Implementation details ==
Provide a default implementation of LaunchpadView.information_type.  It uses the new IInformationType interface to get the InformationType of a context object.  Implement IInformationType on Specification.

== Tests ==
bin/test -t est_view_banner spec

== Demo and Q/A ==
Create a Proprietary blueprint.  Go to every related page.  Their banners should all say the page contains Proprietary information.


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/services/webapp/publisher.py
  lib/lp/registry/interfaces/informationtype.py
  lib/lp/blueprints/model/specification.py
  lib/lp/blueprints/browser/tests/test_specification.py
-- 
https://code.launchpad.net/~abentley/launchpad/fix-banner/+merge/124052
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/fix-banner into lp:launchpad.
=== modified file 'lib/lp/blueprints/browser/tests/test_specification.py'
--- lib/lp/blueprints/browser/tests/test_specification.py	2012-09-12 19:40:39 +0000
+++ lib/lp/blueprints/browser/tests/test_specification.py	2012-09-12 20:30:34 +0000
@@ -269,6 +269,18 @@
             self.set_secrecy(spec, person)
         self.assertEqual(InformationType.PUBLIC, spec.information_type)
 
+    def test_view_banner(self):
+        """The privacy banner should reflect the information_type."""
+        owner = self.factory.makePerson()
+        spec = self.factory.makeSpecification(
+            information_type=InformationType.PROPRIETARY, owner=owner)
+        browser = self.getViewBrowser(spec, '+index', user=owner)
+        self.assertIn('This page contains Proprietary information.',
+                      browser.contents)
+        browser = self.getViewBrowser(spec, '+subscribe', user=owner)
+        self.assertIn('This page contains Proprietary information.',
+                      browser.contents)
+
 
 # canonical_url erroneously returns http://blueprints.launchpad.dev/+new
 NEW_SPEC_FROM_ROOT_URL = 'http://blueprints.launchpad.dev/specs/+new'

=== modified file 'lib/lp/blueprints/model/specification.py'
--- lib/lp/blueprints/model/specification.py	2012-09-12 19:40:39 +0000
+++ lib/lp/blueprints/model/specification.py	2012-09-12 20:30:34 +0000
@@ -81,6 +81,7 @@
 from lp.registry.errors import CannotChangeInformationType
 from lp.registry.interfaces.distribution import IDistribution
 from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.registry.interfaces.informationtype import IInformationType
 from lp.registry.interfaces.person import validate_public_person
 from lp.registry.interfaces.product import IProduct
 from lp.registry.interfaces.productseries import IProductSeries
@@ -130,7 +131,7 @@
 class Specification(SQLBase, BugLinkTargetMixin):
     """See ISpecification."""
 
-    implements(ISpecification, IBugLinkTarget)
+    implements(ISpecification, IBugLinkTarget, IInformationType)
 
     _defaultOrder = ['-priority', 'definition_status', 'name', 'id']
 

=== added file 'lib/lp/registry/interfaces/informationtype.py'
--- lib/lp/registry/interfaces/informationtype.py	1970-01-01 00:00:00 +0000
+++ lib/lp/registry/interfaces/informationtype.py	2012-09-12 20:30:34 +0000
@@ -0,0 +1,21 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+__metaclass__ = type
+__all__ = [
+    'IInformationType',
+    ]
+
+from zope.schema import Choice
+
+from lp import _
+from lp.app.interfaces.launchpad import IPrivacy
+from lp.registry.enums import InformationType
+
+
+class IInformationType(IPrivacy):
+
+    information_type = Choice(
+        title=_('Information Type'),
+        vocabulary=InformationType,
+        )

=== modified file 'lib/lp/services/webapp/publisher.py'
--- lib/lp/services/webapp/publisher.py	2012-09-11 02:01:52 +0000
+++ lib/lp/services/webapp/publisher.py	2012-09-12 20:30:34 +0000
@@ -90,6 +90,7 @@
     )
 from lp.services.webapp.url import urlappend
 from lp.services.webapp.vhosts import allvhosts
+from lp.registry.interfaces.informationtype import IInformationType
 
 # Monkeypatch NotFound to always avoid generating OOPS
 # from NotFound in web service calls.
@@ -301,6 +302,14 @@
         else:
             return False
 
+    @property
+    def information_type(self):
+        """A view has the information_type of its context."""
+        information_typed = IInformationType(self.context, None)
+        if information_typed is None:
+            return None
+        return information_typed.information_type.title
+
     def __init__(self, context, request):
         self.context = context
         self.request = request
@@ -959,7 +968,9 @@
                             nextobj = None
                         else:
                             # Circular import; breaks make.
-                            from lp.services.webapp.breadcrumb import Breadcrumb
+                            from lp.services.webapp.breadcrumb import (
+                                Breadcrumb,
+                            )
                             stepthrough_page = queryMultiAdapter(
                                     (self.context, self.request), name=name)
                             if stepthrough_page:


Follow ups