Merge lp:~jcsackett/launchpad/privacy-banner-with-better-info into lp:launchpad

Proposed by j.c.sackett
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 15305
Proposed branch: lp:~jcsackett/launchpad/privacy-banner-with-better-info
Merge into: lp:launchpad
Prerequisite: lp:~jcsackett/launchpad/simplify-everything
Diff against target: 101 lines (+28/-6)
5 files modified
lib/lp/app/javascript/banners/banner.js (+1/-1)
lib/lp/app/templates/banner-macros.pt (+10/-1)
lib/lp/bugs/browser/bugtask.py (+4/-0)
lib/lp/bugs/javascript/information_type_choice.js (+3/-0)
lib/lp/bugs/javascript/tests/test_information_type_choice.js (+10/-4)
To merge this branch: bzr merge lp:~jcsackett/launchpad/privacy-banner-with-better-info
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+107244@code.launchpad.net

Commit message

Updates the privacy banner to show the appropriate information_type for the bug.

Description of the change

Summary
=======
This branch updates the use of the privacy banner on the bugtask index page to
show the appropriate information type in the banner.

Preimp
======
Spoke with Curtis Hovey, Steve Kowalik.

Implementation
==============
* updateText is updated to set 'text', not 'innerText'; 'text' works better in
  dynamic updates in some browsers.

* lp.bugs.browser.bugtask gets an information_type property, which returns the
  information type title for the associated bug.

* the banner-macro privacy banner is updated to grab the view.information_type
  attribute, if it exists. If it exist, the text is rendered as "This page
  contains $info_type data." If not, the default message of "This page
  contains private data." is used.

* information_type_choice.js uses Banner.updateText to update the privacy
  banner text based on the information_type the bug is changed to via the
  portlet. The corresponding test is also updated.

Tests
=====
bin/test -vvc -t beta -t privacy -t banner -t type_choice --layer=YUI

QA
==
Go play with the privacy portlet information type choice picker on a bug
change. The privacy banner text should update with the information_type.
Reload the page a few times with different information_types; it should load
showing the appropriate message for the info type.

LoC
===
This is part of the disclosure project.

Lint
====

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/banners/beta-notification.js
  lib/lp/app/javascript/banners/tests/test_banner.js
  lib/lp/app/javascript/banners/banner.js
  lib/lp/bugs/templates/bugtarget-macros-filebug.pt
  lib/lp/app/templates/banner-macros.pt
  lib/lp/app/javascript/banners/privacy.js
  lib/lp/app/javascript/banners/tests/test_privacy.js
  lib/lp/bugs/javascript/tests/test_information_type_choice.js
  lib/lp/bugs/browser/bugtask.py
  lib/lp/bugs/javascript/information_type_choice.js

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/banners/banner.js'
2--- lib/lp/app/javascript/banners/banner.js 2012-05-24 20:52:19 +0000
3+++ lib/lp/app/javascript/banners/banner.js 2012-05-24 20:52:20 +0000
4@@ -119,7 +119,7 @@
5 new_text = this.get('notification_text');
6 }
7 text_node = this.get('contentBox').one('.banner-text');
8- text_node.set('innerText', new_text);
9+ text_node.set('text', new_text);
10 },
11
12 }, {
13
14=== modified file 'lib/lp/app/templates/banner-macros.pt'
15--- lib/lp/app/templates/banner-macros.pt 2012-05-24 20:52:19 +0000
16+++ lib/lp/app/templates/banner-macros.pt 2012-05-24 20:52:20 +0000
17@@ -13,7 +13,16 @@
18 <div class="yui3-privacybanner-content">
19 <div class="global-notification">
20 <span class="sprite notification-private"></span>
21- <span class="banner-text">The information on this page is private.</span>
22+ <tal:info_type
23+ define="info_type python: getattr(view, 'information_type', None)">
24+ <span tal:condition="not: info_type" class="banner-text">
25+ The information on this page is private.
26+ </span>
27+ <span tal:condition="info_type" class="banner-text">
28+ <tal:text
29+ content="string: This page contains ${info_type} information."/>
30+ </span>
31+ </tal:info_type>
32 </div>
33 </div>
34 </div>
35
36=== modified file 'lib/lp/bugs/browser/bugtask.py'
37--- lib/lp/bugs/browser/bugtask.py 2012-05-18 05:57:41 +0000
38+++ lib/lp/bugs/browser/bugtask.py 2012-05-24 20:52:20 +0000
39@@ -702,6 +702,10 @@
40 def recommended_canonical_url(self):
41 return canonical_url(self.context.bug, rootsite='bugs')
42
43+ @property
44+ def information_type(self):
45+ return self.context.bug.information_type.title
46+
47 def initialize(self):
48 """Set up the needed widgets."""
49 bug = self.context.bug
50
51=== modified file 'lib/lp/bugs/javascript/information_type_choice.js'
52--- lib/lp/bugs/javascript/information_type_choice.js 2012-05-17 09:45:29 +0000
53+++ lib/lp/bugs/javascript/information_type_choice.js 2012-05-24 20:52:20 +0000
54@@ -42,6 +42,9 @@
55 subscription_ns.update_subscription_status();
56 update_information_type_description(value);
57 if (private_type) {
58+ privacy_banner.updateText(Y.Lang.substitute(
59+ "This page contains {info_type} information.",
60+ { info_type: value }));
61 body.replaceClass('public', 'private');
62 privacy_banner.show();
63 } else {
64
65=== modified file 'lib/lp/bugs/javascript/tests/test_information_type_choice.js'
66--- lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-17 09:45:29 +0000
67+++ lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-24 20:52:20 +0000
68@@ -54,7 +54,8 @@
69 Y.lp.app.banner.privacy.getPrivacyBanner = function () {
70 return {
71 show: function () { Y.fire('test:banner:show'); },
72- hide: function () { Y.fire('test:banner:hide'); }
73+ hide: function () { Y.fire('test:banner:hide'); },
74+ updateText: function () { Y.fire('test:banner:update'); }
75 };
76 };
77 return old_func;
78@@ -88,15 +89,20 @@
79 'Everyone can see this information.',
80 description_node.get('text'));
81 var old_func = this._shim_privacy_banner();
82- var flag = false;
83+ var hide_flag = false;
84+ var update_flag = false;
85 Y.on('test:banner:show', function() {
86- flag = true;
87+ hide_flag = true;
88+ });
89+ Y.on('test:banner:update', function() {
90+ update_flag = true;
91 });
92
93 ns.information_type_save_success('Private');
94 var body = Y.one('body');
95 Y.Assert.isTrue(body.hasClass('private'));
96- Y.Assert.isTrue(flag);
97+ Y.Assert.isTrue(hide_flag);
98+ Y.Assert.isTrue(update_flag);
99 Y.Assert.areEqual('Private', description_node.get('text'));
100 this._unshim_privacy_banner(old_func);
101 },