Merge lp:~kfogel/launchpad/471195-private-bug-body-class-private into lp:launchpad

Proposed by Karl Fogel
Status: Merged
Approved by: Eleanor Berger
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~kfogel/launchpad/471195-private-bug-body-class-private
Merge into: lp:launchpad
Diff against target: 108 lines (+29/-6)
5 files modified
lib/canonical/launchpad/javascript/bugs/bugtask-index.js (+4/-4)
lib/canonical/launchpad/webapp/tales.py (+2/-1)
lib/lp/bugs/adapters/bug.py (+8/-0)
lib/lp/bugs/configure.zcml (+4/-0)
lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py (+11/-1)
To merge this branch: bzr merge lp:~kfogel/launchpad/471195-private-bug-body-class-private
Reviewer Review Type Date Requested Status
Eleanor Berger (community) code Approve
Review via email: mp+20590@code.launchpad.net

Commit message

Ensure that toggling a bug to "private" or "public" sets the bug's body class accordingly.

To post a comment you must log in.
Revision history for this message
Karl Fogel (kfogel) wrote :

Ensure that toggling a bug to "private" or "public" sets the body class accordingly.
Also, test that the pre-existing code that sets the class on the privacy div works too.

Revision history for this message
Eleanor Berger (intellectronica) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/javascript/bugs/bugtask-index.js'
2--- lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2010-02-16 16:29:36 +0000
3+++ lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2010-03-09 18:42:29 +0000
4@@ -525,14 +525,14 @@
5 lp_bug_entry = updated_entry;
6
7 if (private) {
8- privacy_div.removeClass('public');
9- privacy_div.addClass('private');
10+ Y.one('body').replaceClass('public', 'private');
11+ privacy_div.replaceClass('public', 'private');
12 privacy_text.set(
13 'innerHTML',
14 'This report is <strong>private</strong> ');
15 } else {
16- privacy_div.removeClass('private');
17- privacy_div.addClass('public');
18+ Y.one('body').replaceClass('private', 'public');
19+ privacy_div.replaceClass('private', 'public');
20 privacy_text.set(
21 'innerHTML', 'This report is public ');
22 }
23
24=== modified file 'lib/canonical/launchpad/webapp/tales.py'
25--- lib/canonical/launchpad/webapp/tales.py 2010-03-06 21:38:23 +0000
26+++ lib/canonical/launchpad/webapp/tales.py 2010-03-09 18:42:29 +0000
27@@ -540,7 +540,8 @@
28
29 def public_private_css(self):
30 """Return the CSS class that represents the object's privacy."""
31- if IPrivacy.providedBy(self._context) and self._context.private:
32+ privacy = IPrivacy(self._context, None)
33+ if privacy is not None and privacy.private:
34 return 'private'
35 else:
36 return 'public'
37
38=== modified file 'lib/lp/bugs/adapters/bug.py'
39--- lib/lp/bugs/adapters/bug.py 2010-02-15 13:58:03 +0000
40+++ lib/lp/bugs/adapters/bug.py 2010-03-09 18:42:29 +0000
41@@ -6,6 +6,7 @@
42 __metaclass__ = type
43 __all__ = [
44 'bugcomment_to_entry',
45+ 'bugtask_to_privacy',
46 ]
47
48 from zope.component import getMultiAdapter
49@@ -20,3 +21,10 @@
50 """
51 return getMultiAdapter(
52 (comment.bugtask.bug.messages[comment.index], version), IEntry)
53+
54+def bugtask_to_privacy(bugtask):
55+ """Adapt the bugtask to the underlying bug (which implements IPrivacy).
56+
57+ Needed because IBugTask does not implement IPrivacy.
58+ """
59+ return bugtask.bug
60
61=== modified file 'lib/lp/bugs/configure.zcml'
62--- lib/lp/bugs/configure.zcml 2010-02-19 12:31:43 +0000
63+++ lib/lp/bugs/configure.zcml 2010-03-09 18:42:29 +0000
64@@ -265,6 +265,10 @@
65 permission="zope.Public"/>
66 <adapter
67 for="lp.bugs.interfaces.bugtask.IBugTask"
68+ provides="canonical.launchpad.interfaces.launchpad.IPrivacy"
69+ factory="lp.bugs.adapters.bug.bugtask_to_privacy"/>
70+ <adapter
71+ for="lp.bugs.interfaces.bugtask.IBugTask"
72 provides="canonical.launchpad.interfaces.IBug"
73 factory="lp.bugs.model.bugtask.BugTaskToBugAdapter"/>
74 <adapter
75
76=== modified file 'lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py'
77--- lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py 2010-02-18 10:51:34 +0000
78+++ lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py 2010-03-09 18:42:29 +0000
79@@ -1,4 +1,4 @@
80-# Copyright 2009 Canonical Ltd. This software is licensed under the
81+# Copyright 2010 Canonical Ltd. This software is licensed under the
82 # GNU Affero General Public License version 3 (see the file LICENSE).
83
84 import unittest
85@@ -25,6 +25,11 @@
86 PRIVACY_TEXT = u'privacy-text'
87 PRIVACY_TEXT_STRONG = u'//div[@id="privacy-text"]/strong'
88 SECURITY_MESSAGE = u'security-message'
89+IS_PRIVATE_CLASS = (
90+ u"(function() {var classes = element.getAttribute('class').split(' '); "
91+ "return classes.indexOf('private') >= 0"
92+ " && "
93+ "classes.indexOf('public') < 0})()")
94
95
96 class TestSecurityOverlay(WindmillTestCase):
97@@ -79,6 +84,11 @@
98 client.asserts.assertElemJS(
99 xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)
100
101+ # After the bug has been toggled to private, both the document
102+ # as a whole and the privacy div have the class 'private' and
103+ # do not have the class 'public'.
104+ client.asserts.assertElemJS(id=u'document', js=IS_PRIVATE_CLASS)
105+ client.asserts.assertElemJS(id=u'privacy', js=IS_PRIVATE_CLASS)
106
107 # These text changes are made via Javascript, thus avoiding a
108 # complete page load. Let's reload the page, to check that