← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~mbp/launchpad/858618-affecting-me into lp:launchpad

 

Martin Pool has proposed merging lp:~mbp/launchpad/858618-affecting-me into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #858618 in Launchpad itself: "hard to find bugs that affect you in a project"
  https://bugs.launchpad.net/launchpad/+bug/858618

For more details, see:
https://code.launchpad.net/~mbp/launchpad/858618-affecting-me/+merge/76880

This adds a "bugs affecting me" count to the bugtask info portlet, which links to a list of them.  The list is ordered by latest-modified-first, as that seems to best match the case of "find a bug I previously cared about".

I couldn't see any existing tests for the portlet, so I've just tested this interactively for now.  If someone can suggest what to add I would be happy to do it.

Looks like this: https://bugs.launchpad.net/launchpad/+bug/858618/+attachment/2455825/+files/20110925-bugs-affecting-me.png
-- 
https://code.launchpad.net/~mbp/launchpad/858618-affecting-me/+merge/76880
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/858618-affecting-me into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py	2011-09-23 13:25:35 +0000
+++ lib/lp/bugs/browser/bugtask.py	2011-09-25 03:34:26 +0000
@@ -1907,6 +1907,14 @@
             return get_buglisting_search_filter_url(assignee=self.user.name)
 
     @property
+    def my_affecting_bugs_url(self):
+        """A URL to a list of bugs affecting the user, or None."""
+        if self.user is None:
+            return None
+        return get_buglisting_search_filter_url(affecting_me=True,
+            orderby='-date_last_updated')
+
+    @property
     def my_reported_bugs_url(self):
         """A URL to a list of bugs reported by the user, or None."""
         if self.user is None:
@@ -2047,6 +2055,15 @@
         return self.context.searchTasks(params).count()
 
     @property
+    def my_affecting_bugs_count(self):
+        """A count of bugs affecting the user, or None."""
+        if self.user is None:
+            return None
+        params = get_default_search_params(self.user)
+        params.affects_me = True
+        return self.context.searchTasks(params).count()
+
+    @property
     def bugs_with_patches_count(self):
         """A count of unresolved bugs with patches."""
         return self._bug_stats['with_patch']
@@ -2062,7 +2079,9 @@
 
 def get_buglisting_search_filter_url(
         assignee=None, importance=None, status=None, status_upstream=None,
-        has_patches=None, bug_reporter=None):
+        has_patches=None, bug_reporter=None,
+        affecting_me=None,
+        orderby=None):
     """Return the given URL with the search parameters specified."""
     search_params = []
 
@@ -2078,6 +2097,10 @@
         search_params.append(('field.has_patch', 'on'))
     if bug_reporter is not None:
         search_params.append(('field.bug_reporter', bug_reporter))
+    if affecting_me is not None:
+        search_params.append(('field.affects_me', 'on'))
+    if orderby is not None:
+        search_params.append(('orderby', orderby))
 
     query_string = urllib.urlencode(search_params, doseq=True)
 

=== modified file 'lib/lp/bugs/templates/bugtarget-portlet-bugfilters-content.pt'
--- lib/lp/bugs/templates/bugtarget-portlet-bugfilters-content.pt	2011-02-24 15:35:44 +0000
+++ lib/lp/bugs/templates/bugtarget-portlet-bugfilters-content.pt	2011-09-25 03:34:26 +0000
@@ -94,6 +94,20 @@
       </a>
     </td>
   </tr>
+  <tr tal:condition="view/user"
+      tal:define="count view/my_affecting_bugs_count|nothing;
+                  plural string: Bugs affecting me;
+                  singular string: Bug affecting me;">
+    <td class="bugs-count" tal:content="count" />
+    <td class="bugs-link">
+      <a tal:attributes="href string:${view/my_affecting_bugs_url}">
+      <metal:message use-macro="context/@@+base-layout-macros/plural-message"/>
+      </a>
+    </td>
+  </tr>
+
+  <tr><td colspan="2"><br /></td></tr>
+
   <tr tal:define="count view/bugs_with_patches_count|nothing;
                   plural string: Bugs with patches;
                   singular string: Bug with a patch;">