Merge lp:~jcsackett/launchpad/privacy-banner-better-text-ff-redo 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: 15338
Proposed branch: lp:~jcsackett/launchpad/privacy-banner-better-text-ff-redo
Merge into: lp:launchpad
Diff against target: 157 lines (+67/-5)
6 files modified
lib/lp/app/browser/informationtype.py (+2/-0)
lib/lp/app/templates/banner-macros.pt (+10/-1)
lib/lp/bugs/browser/bugtask.py (+13/-0)
lib/lp/bugs/browser/tests/test_bugtask.py (+15/-0)
lib/lp/bugs/javascript/information_type_choice.js (+17/-0)
lib/lp/bugs/javascript/tests/test_information_type_choice.js (+10/-4)
To merge this branch: bzr merge lp:~jcsackett/launchpad/privacy-banner-better-text-ff-redo
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+108071@code.launchpad.net

Description of the change

Summary
=======
A branch was created that shows the type of private information when
applicable (e.g. User Data, Embargoed Security). This branch did not however
factor in the requirement that this behavior only be in effect when the
appropriate feature flags are set.

That branch was rolled back; this branch undoes that rollback and adds the
necessary feature flag checks.

Implementation
==============
The information_type property of the BugtaskIndexView now uses the necessary
feature flags in determining what to return.

The flag indicating use of the term "Privacy" vs "User Data" is now added to
the LP.cache in the same manner as the one that establishes whether to show
information_type in the UI.

The creation of the updated banner text in information_type_choice.js is in
its own small method; it now checks the feature flags to determine how to
update the banner text.

Tests
=====
bin/test -vvct test_bugtask
bin/test -vvct type_choice --layer=YUI

QA
==
Check the text in the privacy banner on a bugtask index page under all
combinations of the relevant feature flags.

LoC
===
This is part of disclosure work.

Lint
====

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/templates/banner-macros.pt
  lib/lp/app/browser/informationtype.py
  lib/lp/bugs/javascript/tests/test_information_type_choice.js
  lib/lp/bugs/browser/tests/test_bugtask.py
  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/browser/informationtype.py'
2--- lib/lp/app/browser/informationtype.py 2012-05-30 05:04:40 +0000
3+++ lib/lp/app/browser/informationtype.py 2012-05-30 22:03:19 +0000
4@@ -29,6 +29,8 @@
5 type.title for type in PRIVATE_INFORMATION_TYPES]
6 cache.objects['show_information_type_in_ui'] = (
7 self.show_information_type_in_ui)
8+ cache.objects['show_userdata_as_private'] = (
9+ self.show_userdata_as_private)
10
11 @property
12 def show_information_type_in_ui(self):
13
14=== modified file 'lib/lp/app/templates/banner-macros.pt'
15--- lib/lp/app/templates/banner-macros.pt 2012-05-29 13:22:21 +0000
16+++ lib/lp/app/templates/banner-macros.pt 2012-05-30 22:03:19 +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-29 13:22:21 +0000
38+++ lib/lp/bugs/browser/bugtask.py 2012-05-30 22:03:19 +0000
39@@ -702,6 +702,19 @@
40 def recommended_canonical_url(self):
41 return canonical_url(self.context.bug, rootsite='bugs')
42
43+ @property
44+ def information_type(self):
45+ use_private_flag = getFeatureFlag(
46+ 'disclosure.display_userdata_as_private.enabled')
47+ info_type_enabled_flag = getFeatureFlag(
48+ 'disclosure.show_information_type_in_ui.enabled')
49+ value = None
50+ if info_type_enabled_flag:
51+ value = self.context.bug.information_type.title
52+ if (use_private_flag and value == InformationType.USERDATA.title):
53+ value = "Private"
54+ return value
55+
56 def initialize(self):
57 """Set up the needed widgets."""
58 bug = self.context.bug
59
60=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
61--- lib/lp/bugs/browser/tests/test_bugtask.py 2012-05-23 14:20:13 +0000
62+++ lib/lp/bugs/browser/tests/test_bugtask.py 2012-05-30 22:03:19 +0000
63@@ -292,6 +292,21 @@
64 'href="/foobar/+bugs?field.tag=depends-on%2B987"',
65 browser.contents)
66
67+ def test_information_type_with_flags(self):
68+ owner = self.factory.makePerson()
69+ bug = self.factory.makeBug(
70+ owner=owner,
71+ information_type=InformationType.USERDATA)
72+ login_person(owner)
73+ bugtask = self.factory.makeBugTask(bug=bug)
74+ features = {'disclosure.show_information_type_in_ui.enabled': True}
75+ with FeatureFixture(features):
76+ view = create_initialized_view(bugtask, name="+index")
77+ self.assertEqual('User Data', view.information_type)
78+ features['disclosure.display_userdata_as_private.enabled'] = True
79+ with FeatureFixture(features):
80+ view = create_initialized_view(bugtask, name="+index")
81+ self.assertEqual('Private', view.information_type)
82
83 class TestBugTasksAndNominationsView(TestCaseWithFactory):
84
85
86=== modified file 'lib/lp/bugs/javascript/information_type_choice.js'
87--- lib/lp/bugs/javascript/information_type_choice.js 2012-05-29 13:22:21 +0000
88+++ lib/lp/bugs/javascript/information_type_choice.js 2012-05-30 22:03:19 +0000
89@@ -34,6 +34,21 @@
90 }
91 };
92
93+namespace.get_information_type_banner_text = function(value) {
94+ console.dir(LP.cache);
95+ var fallback_text = "The information on this page is private.";
96+ var text_template = "This page contains {info_type} information.";
97+
98+ if (value === "User Data" && LP.cache.show_userdata_as_private) {
99+ value = "Private";
100+ }
101+ if (LP.cache.show_information_type_in_ui) {
102+ return Y.Lang.substitute(text_template, {'info_type': value});
103+ } else {
104+ return fallback_text;
105+ }
106+};
107+
108 namespace.information_type_save_success = function(value) {
109 var body = Y.one('body');
110 var private_type = (Y.Array.indexOf(LP.cache.private_types, value) >= 0);
111@@ -42,6 +57,8 @@
112 subscription_ns.update_subscription_status();
113 update_information_type_description(value);
114 if (private_type) {
115+ var banner_text = namespace.get_information_type_banner_text(value);
116+ privacy_banner.updateText(banner_text);
117 body.replaceClass('public', 'private');
118 privacy_banner.show();
119 } else {
120
121=== modified file 'lib/lp/bugs/javascript/tests/test_information_type_choice.js'
122--- lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-29 13:22:21 +0000
123+++ lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-30 22:03:19 +0000
124@@ -54,7 +54,8 @@
125 Y.lp.app.banner.privacy.getPrivacyBanner = function () {
126 return {
127 show: function () { Y.fire('test:banner:show'); },
128- hide: function () { Y.fire('test:banner:hide'); }
129+ hide: function () { Y.fire('test:banner:hide'); },
130+ updateText: function () { Y.fire('test:banner:update'); }
131 };
132 };
133 return old_func;
134@@ -88,15 +89,20 @@
135 'Everyone can see this information.',
136 description_node.get('text'));
137 var old_func = this._shim_privacy_banner();
138- var flag = false;
139+ var hide_flag = false;
140+ var update_flag = false;
141 Y.on('test:banner:show', function() {
142- flag = true;
143+ hide_flag = true;
144+ });
145+ Y.on('test:banner:update', function() {
146+ update_flag = true;
147 });
148
149 ns.information_type_save_success('Private');
150 var body = Y.one('body');
151 Y.Assert.isTrue(body.hasClass('private'));
152- Y.Assert.isTrue(flag);
153+ Y.Assert.isTrue(hide_flag);
154+ Y.Assert.isTrue(update_flag);
155 Y.Assert.areEqual('Private', description_node.get('text'));
156 this._unshim_privacy_banner(old_func);
157 },