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
=== modified file 'lib/canonical/launchpad/javascript/bugs/bugtask-index.js'
--- lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2010-02-16 16:29:36 +0000
+++ lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2010-03-09 18:42:29 +0000
@@ -525,14 +525,14 @@
525 lp_bug_entry = updated_entry;525 lp_bug_entry = updated_entry;
526526
527 if (private) {527 if (private) {
528 privacy_div.removeClass('public');528 Y.one('body').replaceClass('public', 'private');
529 privacy_div.addClass('private');529 privacy_div.replaceClass('public', 'private');
530 privacy_text.set(530 privacy_text.set(
531 'innerHTML',531 'innerHTML',
532 'This report is <strong>private</strong> ');532 'This report is <strong>private</strong> ');
533 } else {533 } else {
534 privacy_div.removeClass('private');534 Y.one('body').replaceClass('private', 'public');
535 privacy_div.addClass('public');535 privacy_div.replaceClass('private', 'public');
536 privacy_text.set(536 privacy_text.set(
537 'innerHTML', 'This report is public ');537 'innerHTML', 'This report is public ');
538 }538 }
539539
=== modified file 'lib/canonical/launchpad/webapp/tales.py'
--- lib/canonical/launchpad/webapp/tales.py 2010-03-06 21:38:23 +0000
+++ lib/canonical/launchpad/webapp/tales.py 2010-03-09 18:42:29 +0000
@@ -540,7 +540,8 @@
540540
541 def public_private_css(self):541 def public_private_css(self):
542 """Return the CSS class that represents the object's privacy."""542 """Return the CSS class that represents the object's privacy."""
543 if IPrivacy.providedBy(self._context) and self._context.private:543 privacy = IPrivacy(self._context, None)
544 if privacy is not None and privacy.private:
544 return 'private'545 return 'private'
545 else:546 else:
546 return 'public'547 return 'public'
547548
=== modified file 'lib/lp/bugs/adapters/bug.py'
--- lib/lp/bugs/adapters/bug.py 2010-02-15 13:58:03 +0000
+++ lib/lp/bugs/adapters/bug.py 2010-03-09 18:42:29 +0000
@@ -6,6 +6,7 @@
6__metaclass__ = type6__metaclass__ = type
7__all__ = [7__all__ = [
8 'bugcomment_to_entry',8 'bugcomment_to_entry',
9 'bugtask_to_privacy',
9 ]10 ]
1011
11from zope.component import getMultiAdapter12from zope.component import getMultiAdapter
@@ -20,3 +21,10 @@
20 """21 """
21 return getMultiAdapter(22 return getMultiAdapter(
22 (comment.bugtask.bug.messages[comment.index], version), IEntry)23 (comment.bugtask.bug.messages[comment.index], version), IEntry)
24
25def bugtask_to_privacy(bugtask):
26 """Adapt the bugtask to the underlying bug (which implements IPrivacy).
27
28 Needed because IBugTask does not implement IPrivacy.
29 """
30 return bugtask.bug
2331
=== modified file 'lib/lp/bugs/configure.zcml'
--- lib/lp/bugs/configure.zcml 2010-02-19 12:31:43 +0000
+++ lib/lp/bugs/configure.zcml 2010-03-09 18:42:29 +0000
@@ -265,6 +265,10 @@
265 permission="zope.Public"/>265 permission="zope.Public"/>
266 <adapter266 <adapter
267 for="lp.bugs.interfaces.bugtask.IBugTask"267 for="lp.bugs.interfaces.bugtask.IBugTask"
268 provides="canonical.launchpad.interfaces.launchpad.IPrivacy"
269 factory="lp.bugs.adapters.bug.bugtask_to_privacy"/>
270 <adapter
271 for="lp.bugs.interfaces.bugtask.IBugTask"
268 provides="canonical.launchpad.interfaces.IBug"272 provides="canonical.launchpad.interfaces.IBug"
269 factory="lp.bugs.model.bugtask.BugTaskToBugAdapter"/>273 factory="lp.bugs.model.bugtask.BugTaskToBugAdapter"/>
270 <adapter274 <adapter
271275
=== modified file 'lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py'
--- lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py 2010-02-18 10:51:34 +0000
+++ lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py 2010-03-09 18:42:29 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4import unittest4import unittest
@@ -25,6 +25,11 @@
25PRIVACY_TEXT = u'privacy-text'25PRIVACY_TEXT = u'privacy-text'
26PRIVACY_TEXT_STRONG = u'//div[@id="privacy-text"]/strong'26PRIVACY_TEXT_STRONG = u'//div[@id="privacy-text"]/strong'
27SECURITY_MESSAGE = u'security-message'27SECURITY_MESSAGE = u'security-message'
28IS_PRIVATE_CLASS = (
29 u"(function() {var classes = element.getAttribute('class').split(' '); "
30 "return classes.indexOf('private') >= 0"
31 " && "
32 "classes.indexOf('public') < 0})()")
2833
2934
30class TestSecurityOverlay(WindmillTestCase):35class TestSecurityOverlay(WindmillTestCase):
@@ -79,6 +84,11 @@
79 client.asserts.assertElemJS(84 client.asserts.assertElemJS(
80 xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)85 xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)
8186
87 # After the bug has been toggled to private, both the document
88 # as a whole and the privacy div have the class 'private' and
89 # do not have the class 'public'.
90 client.asserts.assertElemJS(id=u'document', js=IS_PRIVATE_CLASS)
91 client.asserts.assertElemJS(id=u'privacy', js=IS_PRIVATE_CLASS)
8292
83 # These text changes are made via Javascript, thus avoiding a93 # These text changes are made via Javascript, thus avoiding a
84 # complete page load. Let's reload the page, to check that94 # complete page load. Let's reload the page, to check that