← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/launchpad/sub-search-ui-bug-656823-devel into lp:launchpad/devel

 

Gavin Panella has proposed merging lp:~allenap/launchpad/sub-search-ui-bug-656823-devel into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #656823 Subscribing to a search lacks a UI
  https://bugs.launchpad.net/bugs/656823


This is lp:~allenap/launchpad/sub-search-ui-bug-656823, which has already been reviewed favourably, rebased onto devel.
-- 
https://code.launchpad.net/~allenap/launchpad/sub-search-ui-bug-656823-devel/+merge/39545
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/sub-search-ui-bug-656823-devel into lp:launchpad/devel.
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py	2010-10-24 13:02:07 +0000
+++ lib/lp/registry/browser/person.py	2010-10-28 16:31:43 +0000
@@ -2344,14 +2344,16 @@
         return self.getSearchPageHeading()
 
 
-class PersonSubscriptionsView(BugTaskSearchListingView):
+class PersonSubscriptionsView(LaunchpadView):
     """All the subscriptions for a person."""
 
     page_title = 'Subscriptions'
 
     def subscribedBugTasks(self):
-        """Return a BatchNavigator for distinct bug tasks to which the
-        person is subscribed."""
+        """
+        Return a BatchNavigator for distinct bug tasks to which the person is
+        subscribed.
+        """
         bug_tasks = self.context.searchTasks(None, user=self.user,
             order_by='-date_last_updated',
             status=(BugTaskStatus.NEW,
@@ -2364,38 +2366,37 @@
             bug_subscriber=self.context)
 
         sub_bug_tasks = []
-        sub_bugs = []
+        sub_bugs = set()
 
+        # XXX: GavinPanella 2010-10-08 bug=656904: This materializes the
+        # entire result set. It would probably be more efficient implemented
+        # with a pre_iter_hook on a DecoratedResultSet.
         for task in bug_tasks:
+            # We order the bugtasks by date_last_updated but we always display
+            # the default task for the bug. This is to avoid ordering issues
+            # in tests and also prevents user confusion (because nothing is
+            # more confusing than your subscription targets changing seemingly
+            # at random).
             if task.bug not in sub_bugs:
-                # We order the bugtasks by date_last_updated but we
-                # always display the default task for the bug. This is
-                # to avoid ordering issues in tests and also prevents
-                # user confusion (because nothing is more confusing than
-                # your subscription targets changing seemingly at
-                # random).
+                # XXX: GavinPanella 2010-10-08 bug=656904: default_bugtask
+                # causes a query to be executed. It would be more efficient to
+                # get the default bugtask in bulk, in a pre_iter_hook on a
+                # DecoratedResultSet perhaps.
                 sub_bug_tasks.append(task.bug.default_bugtask)
-                sub_bugs.append(task.bug)
+                sub_bugs.add(task.bug)
+
         return BatchNavigator(sub_bug_tasks, self.request)
 
     def canUnsubscribeFromBugTasks(self):
-        viewed_person = self.context
-        if self.user is None:
-            return False
-        elif viewed_person == self.user:
-            return True
-        elif (viewed_person.is_team and
-              self.user.inTeam(viewed_person)):
-            return True
+        """Can the current user unsubscribe from the bug tasks shown?"""
+        return (self.user is not None and
+                self.user.inTeam(self.context))
 
-    def getSubscriptionsPageHeading(self):
+    @property
+    def label(self):
         """The header for the subscriptions page."""
         return "Subscriptions for %s" % self.context.displayname
 
-    @property
-    def label(self):
-        return self.getSubscriptionsPageHeading()
-
 
 class PersonVouchersView(LaunchpadFormView):
     """Form for displaying and redeeming commercial subscription vouchers."""

=== modified file 'lib/lp/registry/templates/person-subscriptions.pt'
--- lib/lp/registry/templates/person-subscriptions.pt	2010-09-28 20:55:37 +0000
+++ lib/lp/registry/templates/person-subscriptions.pt	2010-10-28 16:31:43 +0000
@@ -1,71 +1,75 @@
 <html
-  xmlns="http://www.w3.org/1999/xhtml";
-  xmlns:tal="http://xml.zope.org/namespaces/tal";
-  xmlns:metal="http://xml.zope.org/namespaces/metal";
-  xmlns:i18n="http://xml.zope.org/namespaces/i18n";
-  xml:lang="en"
-  lang="en"
-  dir="ltr"
-  metal:use-macro="view/macro:page/main_side"
-  i18n:domain="launchpad"
->
+    xmlns="http://www.w3.org/1999/xhtml";
+    xmlns:tal="http://xml.zope.org/namespaces/tal";
+    xmlns:metal="http://xml.zope.org/namespaces/metal";
+    xmlns:i18n="http://xml.zope.org/namespaces/i18n";
+    xml:lang="en"
+    lang="en"
+    dir="ltr"
+    metal:use-macro="view/macro:page/main_only"
+    i18n:domain="launchpad">
   <body>
 
   <div metal:fill-slot="main"
-    tal:define="sub_bugs view/subscribedBugTasks;
-    sub_bug_batch sub_bugs/currentBatch">
+       tal:define="display_name context/fmt:displayname;
+                   sub_bugs view/subscribedBugTasks;
+                   sub_bug_batch sub_bugs/currentBatch">
+
     <tal:no_subscribed_bugs condition="not: sub_bug_batch|nothing">
-      <p><tal:person content="context/fmt:displayname">Sample
-      Person</tal:person> does not have any direct bug subscriptions.</p>
+      <p>
+        <tal:person content="display_name">Sample
+        Person</tal:person> does not have any direct bug subscriptions.
+      </p>
     </tal:no_subscribed_bugs>
 
     <tal:subscribed_bugs condition="sub_bug_batch|nothing">
       <p>
-      Direct bug subscriptions for
-      <tal:person content="context/fmt:displayname">Sample Person</tal:person>
+        Direct bug subscriptions for
+        <tal:person content="display_name">Sample Person</tal:person>
       </p>
-    <div tal:replace="structure sub_bugs/@@+navigation-links-lower"/>
-    <table id="bug_subscriptions" class="listing">
-    <thead>
-      <tr>
-        <th colspan="3">Summary</th>
-        <th>
-          In
-        </th>
-        <th tal:condition="view/canUnsubscribeFromBugTasks">
-        </th>
-      </tr>
-    </thead>
-    <tr tal:repeat="sub_bug_task sub_bug_batch">
-              <td class="icon left">
-                <span tal:replace="structure sub_bug_task/image:icon" />
-              </td>
-              <td id="bug_number" style="text-align: right">
-                <span tal:replace="sub_bug_task/bug/id" />
-              </td>
-              <td>
-                <a tal:attributes="href sub_bug_task/fmt:url"
-                   tal:content="sub_bug_task/bug/title" />
-              </td>
-        <td tal:content="sub_bug_task/bugtargetdisplayname"
-            tal:condition="sub_bug_task/bugtargetdisplayname|nothing"
-        >mozilla-firefox (Ubuntu)</td>
-        <td tal:condition="view/canUnsubscribeFromBugTasks"
-            align="center">
-            <a
-               tal:attributes="
-               title string:Unsubscribe ${context/fmt:displayname} from bug ${sub_bug_task/bug/id};
-                 id string:unsubscribe-subscriber-${context/id};
-                 href string:${sub_bug_task/fmt:url}/+subscribe;
-               "
-            >
+      <tal:multipage condition="sub_bugs/has_multiple_pages">
+        <tal:navigation
+            replace="structure sub_bugs/@@+navigation-links-upper"/>
+      </tal:multipage>
+      <table id="bug_subscriptions" class="listing">
+        <thead>
+          <tr>
+            <th colspan="3">Summary</th>
+            <th>
+              In
+            </th>
+            <th tal:condition="view/canUnsubscribeFromBugTasks">
+            </th>
+          </tr>
+        </thead>
+        <tr tal:repeat="sub_bug_task sub_bug_batch">
+          <td class="icon left">
+            <span tal:replace="structure sub_bug_task/image:icon" />
+          </td>
+          <td style="text-align: right">
+            <span tal:replace="sub_bug_task/bug/id" />
+          </td>
+          <td>
+            <a tal:attributes="href sub_bug_task/fmt:url"
+               tal:content="sub_bug_task/bug/title" />
+          </td>
+          <td tal:content="sub_bug_task/bugtargetdisplayname"
+              tal:condition="sub_bug_task/bugtargetdisplayname|nothing" />
+          <td tal:condition="view/canUnsubscribeFromBugTasks" align="center">
+            <a tal:attributes="id string:unsubscribe-subscriber-${context/id};
+                               href sub_bug_task/fmt:url/+subscribe;
+                               title string:Unsubscribe ${display_name} from bug ${sub_bug_task/bug/id};">
               <img src="/@@/edit"
-              tal:attributes="id string:unsubscribe-icon-${context/id};
-                              position string:relative"/>
+                   tal:attributes="id string:unsubscribe-icon-${context/id};
+                                   position string:relative"/>
             </a>
           </td>
-      </tr>
-    </table>
+        </tr>
+      </table>
+      <tal:multipage condition="sub_bugs/has_multiple_pages">
+        <tal:navigation
+            replace="structure sub_bugs/@@+navigation-links-lower"/>
+      </tal:multipage>
     </tal:subscribed_bugs>
 
   </div>