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
=== modified file 'lib/lp/app/javascript/banners/banner.js'
--- lib/lp/app/javascript/banners/banner.js 2012-05-24 20:52:19 +0000
+++ lib/lp/app/javascript/banners/banner.js 2012-05-24 20:52:20 +0000
@@ -119,7 +119,7 @@
119 new_text = this.get('notification_text'); 119 new_text = this.get('notification_text');
120 }120 }
121 text_node = this.get('contentBox').one('.banner-text');121 text_node = this.get('contentBox').one('.banner-text');
122 text_node.set('innerText', new_text);122 text_node.set('text', new_text);
123 },123 },
124124
125}, {125}, {
126126
=== modified file 'lib/lp/app/templates/banner-macros.pt'
--- lib/lp/app/templates/banner-macros.pt 2012-05-24 20:52:19 +0000
+++ lib/lp/app/templates/banner-macros.pt 2012-05-24 20:52:20 +0000
@@ -13,7 +13,16 @@
13 <div class="yui3-privacybanner-content">13 <div class="yui3-privacybanner-content">
14 <div class="global-notification">14 <div class="global-notification">
15 <span class="sprite notification-private"></span>15 <span class="sprite notification-private"></span>
16 <span class="banner-text">The information on this page is private.</span>16 <tal:info_type
17 define="info_type python: getattr(view, 'information_type', None)">
18 <span tal:condition="not: info_type" class="banner-text">
19 The information on this page is private.
20 </span>
21 <span tal:condition="info_type" class="banner-text">
22 <tal:text
23 content="string: This page contains ${info_type} information."/>
24 </span>
25 </tal:info_type>
17 </div>26 </div>
18 </div>27 </div>
19 </div>28 </div>
2029
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2012-05-18 05:57:41 +0000
+++ lib/lp/bugs/browser/bugtask.py 2012-05-24 20:52:20 +0000
@@ -702,6 +702,10 @@
702 def recommended_canonical_url(self):702 def recommended_canonical_url(self):
703 return canonical_url(self.context.bug, rootsite='bugs')703 return canonical_url(self.context.bug, rootsite='bugs')
704704
705 @property
706 def information_type(self):
707 return self.context.bug.information_type.title
708
705 def initialize(self):709 def initialize(self):
706 """Set up the needed widgets."""710 """Set up the needed widgets."""
707 bug = self.context.bug711 bug = self.context.bug
708712
=== modified file 'lib/lp/bugs/javascript/information_type_choice.js'
--- lib/lp/bugs/javascript/information_type_choice.js 2012-05-17 09:45:29 +0000
+++ lib/lp/bugs/javascript/information_type_choice.js 2012-05-24 20:52:20 +0000
@@ -42,6 +42,9 @@
42 subscription_ns.update_subscription_status();42 subscription_ns.update_subscription_status();
43 update_information_type_description(value);43 update_information_type_description(value);
44 if (private_type) {44 if (private_type) {
45 privacy_banner.updateText(Y.Lang.substitute(
46 "This page contains {info_type} information.",
47 { info_type: value }));
45 body.replaceClass('public', 'private');48 body.replaceClass('public', 'private');
46 privacy_banner.show();49 privacy_banner.show();
47 } else {50 } else {
4851
=== modified file 'lib/lp/bugs/javascript/tests/test_information_type_choice.js'
--- lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-17 09:45:29 +0000
+++ lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-24 20:52:20 +0000
@@ -54,7 +54,8 @@
54 Y.lp.app.banner.privacy.getPrivacyBanner = function () {54 Y.lp.app.banner.privacy.getPrivacyBanner = function () {
55 return {55 return {
56 show: function () { Y.fire('test:banner:show'); },56 show: function () { Y.fire('test:banner:show'); },
57 hide: function () { Y.fire('test:banner:hide'); }57 hide: function () { Y.fire('test:banner:hide'); },
58 updateText: function () { Y.fire('test:banner:update'); }
58 };59 };
59 };60 };
60 return old_func;61 return old_func;
@@ -88,15 +89,20 @@
88 'Everyone can see this information.',89 'Everyone can see this information.',
89 description_node.get('text'));90 description_node.get('text'));
90 var old_func = this._shim_privacy_banner();91 var old_func = this._shim_privacy_banner();
91 var flag = false;92 var hide_flag = false;
93 var update_flag = false;
92 Y.on('test:banner:show', function() {94 Y.on('test:banner:show', function() {
93 flag = true;95 hide_flag = true;
96 });
97 Y.on('test:banner:update', function() {
98 update_flag = true;
94 });99 });
95100
96 ns.information_type_save_success('Private');101 ns.information_type_save_success('Private');
97 var body = Y.one('body');102 var body = Y.one('body');
98 Y.Assert.isTrue(body.hasClass('private'));103 Y.Assert.isTrue(body.hasClass('private'));
99 Y.Assert.isTrue(flag);104 Y.Assert.isTrue(hide_flag);
105 Y.Assert.isTrue(update_flag);
100 Y.Assert.areEqual('Private', description_node.get('text'));106 Y.Assert.areEqual('Private', description_node.get('text'));
101 this._unshim_privacy_banner(old_func);107 this._unshim_privacy_banner(old_func);
102 },108 },