← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/liar-liar-pants-on-fiar-bug-193870 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/liar-liar-pants-on-fiar-bug-193870 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #193870 Source package page makes false claims about "Bug subscriptions"
  https://bugs.launchpad.net/bugs/193870


This branch clears up some confusing UI in the structural subscribers
portlet. It's a fairly simple change, which swaps out the existing
TAL-based logic for a simple LaunchpadView which generates the necessary
labels.

I've added a unit test to cover the new labels and have updated
pagetests where appropriate.
-- 
https://code.launchpad.net/~gmb/launchpad/liar-liar-pants-on-fiar-bug-193870/+merge/42227
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/liar-liar-pants-on-fiar-bug-193870 into lp:launchpad.
=== modified file 'lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt'
--- lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt	2010-11-23 13:26:06 +0000
+++ lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt	2010-11-30 11:47:34 +0000
@@ -17,12 +17,12 @@
 
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+subscribe')
-    >>> print extract_text(find_portlet(browser.contents, 'Bug subscriptions'))
-    Bug subscriptions
-      For Ubuntu Linux:
+    >>> print extract_text(find_portlet(browser.contents, 'Subscribers'))
+    Subscribers
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
-And subscribe some people to the Firefox source package in Ubuntu.
+And subscribe some people to the Firefox source package in ubuntu.
 
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+source/mozilla-firefox')
@@ -43,14 +43,14 @@
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+source/mozilla-firefox/+subscribe')
     >>> print extract_text(find_portlet(
-    ...     browser.contents, 'Bug subscriptions')).encode(
+    ...     browser.contents, 'Subscribers')).encode(
     ...     'ascii', 'backslashreplace')
-    Bug subscriptions
-      For...mozilla-firefox...package in Ubuntu:
+    Subscribers
+      To all bugs in mozilla-firefox in ubuntu:
         Foo Bar
         Landscape Developers
         Sample Person
-      For Ubuntu Linux:
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
 Sample Person can also unsubscribe himself and the Landscape team.
@@ -63,11 +63,11 @@
     >>> browser.getControl('Save these changes').click()
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+source/mozilla-firefox/+subscribe')
-    >>> print extract_text(find_portlet(browser.contents, 'Bug subscriptions'))
-    Bug subscriptions
-      For...mozilla-firefox...package in Ubuntu:
+    >>> print extract_text(find_portlet(browser.contents, 'Subscribers'))
+    Subscribers
+      To all bugs in mozilla-firefox in ubuntu:
         Foo Bar
-      For Ubuntu Linux:
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
 
@@ -110,12 +110,12 @@
 
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+source/mozilla-firefox/+subscribe')
-    >>> print extract_text(find_portlet(browser.contents, 'Bug subscriptions'))
-    Bug subscriptions
-      For...mozilla-firefox...package in Ubuntu:
+    >>> print extract_text(find_portlet(browser.contents, 'Subscribers'))
+    Subscribers
+      To all bugs in mozilla-firefox in ubuntu:
         Foo Bar
         No Privileges Person
-      For Ubuntu Linux:
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
 ...has an entry in the "Remove subscriptions" list...
@@ -132,11 +132,11 @@
     public bugs in "mozilla-firefox in ubuntu".
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+source/mozilla-firefox/+subscribe')
-    >>> print extract_text(find_portlet(browser.contents, 'Bug subscriptions'))
-    Bug subscriptions
-      For...mozilla-firefox...package in Ubuntu:
+    >>> print extract_text(find_portlet(browser.contents, 'Subscribers'))
+    Subscribers
+      To all bugs in mozilla-firefox in ubuntu:
         Foo Bar
-      For Ubuntu Linux:
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
 The checkbox to unsubscribe No Privileges Person is no longer present on
@@ -158,11 +158,11 @@
 and to add Sample Person is now silently ignored, because LaunchpadFormView
 purges the submitted form data from now unexpected values.
 
-    >>> print extract_text(find_portlet(browser.contents, 'Bug subscriptions'))
-    Bug subscriptions
-      For...mozilla-firefox...package in Ubuntu:
+    >>> print extract_text(find_portlet(browser.contents, 'Subscribers'))
+    Subscribers
+      To all bugs in mozilla-firefox in ubuntu:
         Foo Bar
-      For Ubuntu Linux:
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
     >>> remove_other = browser.getControl('\xa0Foo Bar')
@@ -172,11 +172,11 @@
     >>> browser.getControl('Save these changes').click()
     >>> browser.open(
     ... 'http://bugs.launchpad.dev/ubuntu/+source/mozilla-firefox/+subscribe')
-    >>> print extract_text(find_portlet(browser.contents, 'Bug subscriptions'))
-    Bug subscriptions
-      For...mozilla-firefox...package in Ubuntu:
+    >>> print extract_text(find_portlet(browser.contents, 'Subscribers'))
+    Subscribers
+      To all bugs in mozilla-firefox in ubuntu:
         Foo Bar
-      For Ubuntu Linux:
+      To all Ubuntu Linux bugs:
         Landscape Developers
 
 When Sample Person now visits the bug subscription page, he no longer sees

=== modified file 'lib/lp/registry/browser/configure.zcml'
--- lib/lp/registry/browser/configure.zcml	2010-11-22 23:08:45 +0000
+++ lib/lp/registry/browser/configure.zcml	2010-11-30 11:47:34 +0000
@@ -2312,7 +2312,9 @@
         name="+portlet-structural-subscribers"
         facet="bugs"
         permission="zope.Public"
+        class="lp.registry.browser.structuralsubscription.StructuralSubscribersPortletView"
         template="../templates/structural-subscription-target-portlet-subscribers.pt"/>
+
     <browser:url
         for="lp.registry.interfaces.structuralsubscription.IStructuralSubscription"
         path_expression="string:+subscription/${subscriber/name}"

=== modified file 'lib/lp/registry/browser/structuralsubscription.py'
--- lib/lp/registry/browser/structuralsubscription.py	2010-11-24 10:49:07 +0000
+++ lib/lp/registry/browser/structuralsubscription.py	2010-11-30 11:47:34 +0000
@@ -7,6 +7,7 @@
     'StructuralSubscriptionMenuMixin',
     'StructuralSubscriptionTargetTraversalMixin',
     'StructuralSubscriptionView',
+    'StructuralSubscribersPortletView',
     ]
 
 from operator import attrgetter
@@ -24,6 +25,7 @@
 
 from canonical.launchpad.webapp import (
     canonical_url,
+    LaunchpadView,
     stepthrough,
     )
 from canonical.launchpad.webapp.authorization import check_permission
@@ -366,3 +368,21 @@
             return Link('+subscribe', text, icon=icon, enabled=False)
         else:
             return Link('+subscribe', text, icon=icon, enabled=enabled)
+
+
+class StructuralSubscribersPortletView(LaunchpadView):
+    """A simple view for displaying the subscribers portlet."""
+
+    @property
+    def target_label(self):
+        """Return the target label for the portlet."""
+        if IDistributionSourcePackage.providedBy(self.context):
+            return "To all bugs in %s" % self.context.displayname
+        else:
+            return "To all %s bugs" % self.context.title
+
+    @property
+    def parent_target_label(self):
+        """Return the target label for the portlet."""
+        return (
+            "To all %s bugs" % self.context.parent_subscription_target.title)

=== modified file 'lib/lp/registry/browser/tests/test_structuralsubscription.py'
--- lib/lp/registry/browser/tests/test_structuralsubscription.py	2010-11-24 10:49:07 +0000
+++ lib/lp/registry/browser/tests/test_structuralsubscription.py	2010-11-30 11:47:34 +0000
@@ -3,8 +3,6 @@
 
 """Tests for structural subscription traversal."""
 
-import unittest
-
 from lazr.restful.testing.webservice import FakeRequest
 from zope.publisher.interfaces import NotFound
 
@@ -262,6 +260,7 @@
             self.assertIs(
                 None, form_fields.get('bug_notification_level'))
 
+
 class TestProductSeriesAdvancedSubscriptionFeatures(
     TestStructuralSubscriptionAdvancedFeaturesBase):
     """Test advanced subscription features for ProductSeries."""
@@ -310,3 +309,50 @@
             self.assertEqual(
                 canonical_url(target), view.next_url,
                 "Next URL does not match target's canonical_url.")
+
+
+class TestStructuralSubscribersPortletViewBase(TestCaseWithFactory):
+    """General tests for the StructuralSubscribersPortletView."""
+
+    layer = DatabaseFunctionalLayer
+
+    def setUp(self):
+        super(TestStructuralSubscribersPortletViewBase, self).setUp()
+        self.setUpTarget()
+        self.view = create_initialized_view(
+            self.target, name='+portlet-structural-subscribers')
+
+    def setUpTarget(self):
+        project = self.factory.makeProject()
+        self.target = self.factory.makeProduct(project=project)
+
+    def test_target_label(self):
+        # The target_label attribute of StructuralSubscribersPortletView
+        # returns the correct label for the current
+        # StructuralSubscriptionTarget.
+        self.assertEqual(
+            "To all %s bugs" % self.target.title, self.view.target_label)
+
+    def test_parent_target_label(self):
+        # The parent_target_label attribute of
+        # StructuralSubscribersPortletView returns the correct label for
+        # the current parent StructuralSubscriptionTarget.
+        self.assertEqual(
+            "To all %s bugs" % self.target.parent_subscription_target.title,
+            self.view.parent_target_label)
+
+
+class TestSourcePackageStructuralSubscribersPortletView(
+    TestStructuralSubscribersPortletViewBase):
+
+    def setUpTarget(self):
+        distribution = self.factory.makeDistribution()
+        sourcepackage = self.factory.makeSourcePackageName()
+        self.target = distribution.getSourcePackage(sourcepackage.name)
+
+    def test_target_label(self):
+        # For DistributionSourcePackages the target_label attribute uses
+        # the target's displayname rather than its title.
+        self.assertEqual(
+            "To all bugs in %s" % self.target.displayname,
+            self.view.target_label)

=== modified file 'lib/lp/registry/templates/structural-subscription-target-portlet-subscribers.pt'
--- lib/lp/registry/templates/structural-subscription-target-portlet-subscribers.pt	2009-12-05 18:37:28 +0000
+++ lib/lp/registry/templates/structural-subscription-target-portlet-subscribers.pt	2010-11-30 11:47:34 +0000
@@ -4,13 +4,13 @@
   xmlns:i18n="http://xml.zope.org/namespaces/i18n";
   class="portlet" id="portlet-structural-subscribers">
 
-  <h2>Bug subscriptions</h2>
+  <h2>Subscribers</h2>
 
   <div class="portletBody portletContent"
        tal:define="subscriptions context/bug_subscriptions;
                    parent_target context/parent_subscription_target;
                    target_type context/target_type_display">
-    <b>For <tal:target-title replace="context/title" />:</b>
+    <b tal:content="view/target_label">To all Foobar bugs</b>:
     <br />
     <div tal:condition="subscriptions">
       <ul>
@@ -28,7 +28,7 @@
       <br /><br />
     </div>
     <tal:parent-subscriptions condition="parent_target">
-      <b tal:content="string:For ${parent_target/title}:">For Ubuntu:</b>
+      <b tal:content="view/parent_target_label">For Ubuntu</b>:
       <br />
       <div tal:condition="parent_target/bug_subscriptions">
         <ul>

=== modified file 'lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt'
--- lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt	2010-11-19 14:48:16 +0000
+++ lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt	2010-11-30 11:47:34 +0000
@@ -335,7 +335,7 @@
 -------------------------------------
 
 The page has a side-bar with a global actions menu, a "Get Involved"
-menu, and a "Bug subscriptions" portlet.
+menu, and a "Subscribers" portlet.
 
     >>> print extract_text(
     ...     find_tag_by_id(user_browser.contents, 'global-actions'))
@@ -352,7 +352,7 @@
     >>> print extract_text(
     ...     find_tag_by_id(user_browser.contents,
     ...                    'portlet-structural-subscribers'))
-    Bug subscriptions
+    Subscribers
     ...
 
 (see bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt for more