← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jcsackett/launchpad/privacy-notifications-on-branches into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/privacy-notifications-on-branches into lp:launchpad with lp:~jcsackett/launchpad/reusable-notification-setup as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #814414 in Launchpad itself: "private merge proposal has no privacy ribbon"
  https://bugs.launchpad.net/launchpad/+bug/814414
  Bug #819401 in Launchpad itself: "No privacy ribbon on private branches"
  https://bugs.launchpad.net/launchpad/+bug/819401

For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/privacy-notifications-on-branches/+merge/70050

Summary
=======
We're updating privacy display; this branch extends the new privacy notifications to code contexts, e.g. branches and merge proposals.

Preimplementation
=================
Some discussion with Curtis Hovey; mostly this is a continuation of earlier established work.

Implementation
==============
lib/lp/app/browser/tales.py
---------------------------
The public_private_css branch formatter has been updated to work with objects that do not implement IPrivacy. Most objects which have a private attribute to do so by implementing that interface, but branches do not b/c they have particular security concerns. The public_private_css
now uses the private attribute on a given context if it exists and the given context does not implement IPrivacy.

lib/lp/code/templates/branch-index.pt
lib/lp/code/templates/branchmergeproposal-index.pt
--------------------------------------------------
The javascript for the new privacy notifications was added to the templates.

Tests
=====
bin/test -m lp.code.browser

QA
==
Check merge proposals and branches. In cases where they are private, the ribbon should display. In cases where they are public, it should not.

When it displays, clicking hide on a branch page should highlight the privacy portlet (as it does on bug index pages). It should simply be dismissed on merge proposals, as with bug comments.

Lint
====
Linting changed files:
  lib/lp/app/browser/tales.py
  lib/lp/code/templates/branch-index.pt
  lib/lp/code/templates/branchmergeproposal-index.pt

-- 
https://code.launchpad.net/~jcsackett/launchpad/privacy-notifications-on-branches/+merge/70050
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/privacy-notifications-on-branches into lp:launchpad.
=== modified file 'lib/lp/app/browser/tales.py'
--- lib/lp/app/browser/tales.py	2011-07-29 18:30:49 +0000
+++ lib/lp/app/browser/tales.py	2011-08-01 16:47:26 +0000
@@ -633,7 +633,11 @@
     def public_private_css(self):
         """Return the CSS class that represents the object's privacy."""
         privacy = IPrivacy(self._context, None)
-        if privacy is not None and privacy.private:
+        if (privacy is None and
+            hasattr(self._context, 'private') and
+            self._context.private):
+                return 'private'
+        elif privacy is not None and privacy.private:
             return 'private'
         else:
             return 'public'

=== modified file 'lib/lp/code/templates/branch-index.pt'
--- lib/lp/code/templates/branch-index.pt	2011-07-06 14:54:46 +0000
+++ lib/lp/code/templates/branch-index.pt	2011-08-01 16:47:26 +0000
@@ -50,6 +50,24 @@
         }, window);
     });
   "/>
+
+  <tal:if condition="request/features/bugs.private_notification.enabled">
+  <script>
+      LPS.use('base', 'node', 'lp.app.privacy', function(Y) {
+          Y.on("domready", function () {
+              if (Y.one(document.body).hasClass('private')) {
+                  var config = {
+                      notification_text: 'This is a private branch',
+                      hidden: true
+                  };
+                  Y.lp.app.privacy.setup_privacy_notification(config);
+                  Y.lp.app.privacy.display_privacy_notification(true);
+              }
+          });
+      });
+  </script>
+  </tal:if>
+
 </metal:block>
 
 <body>

=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
--- lib/lp/code/templates/branchmergeproposal-index.pt	2011-07-20 03:31:29 +0000
+++ lib/lp/code/templates/branchmergeproposal-index.pt	2011-08-01 16:47:26 +0000
@@ -48,6 +48,22 @@
       padding-bottom: 10px;
     }
   </style>
+  <tal:if condition="request/features/bugs.private_notification.enabled">
+  <script>
+      LPS.use('base', 'node', 'lp.app.privacy', function(Y) {
+          Y.on("domready", function () {
+              if (Y.one(document.body).hasClass('private')) {
+                  var config = {
+                      notification_text: 'This merge proposal involves private branches',
+                      hidden: true
+                  };
+                  Y.lp.app.privacy.setup_privacy_notification(config);
+                  Y.lp.app.privacy.display_privacy_notification(false);
+              }
+          });
+      });
+  </script>
+  </tal:if>
 </metal:block>
 
 <tal:registering metal:fill-slot="registering">