← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~brian-murray/launchpad/limited-subscriptions-page into lp:launchpad/devel

 

Brian Murray has proposed merging lp:~brian-murray/launchpad/limited-subscriptions-page into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


= Summary =

This branch is the start of a +subscriptions page for people and teams that will display information about all items that people are subscribed to in Launchpad and allow them to unsubscribe from those items.

As this is the first revision only direct bug subscriptions have been included and the page is not yet linked to.

== Pre-implementation notes ==

Deryck and I talked about this and decided that it would be worthwhile to show duplicate bugs as these can be harder for people to unsubscribe from these.  I've also decided to include Invalid as these can receive noisy traffic.

== Implementation details ==

lib/lp/registry/browser/configure.zcml
    add in +subscriptions page

lib/lp/registry/browser/person.py
    add in PersonSubscriptionsView class
    subscribedBugTasks() returns only one task per bug to prevent duplicates showing up as you can only unsubscribe from bugs not bug tasks
    fix a typo in getSimpleSearchURL()

lib/lp/registry/stories/person/xx-person-subscriptions.txt
    created a new test for the +subscriptions page

lib/lp/registry/templates/person-subscriptions.pt
    created the +subscriptions page

== Tests ==

bin/test -cvvt xx-person-subscriptions.txt

== Demo and QA ==

Login in as sample person and go to http://launchpad.dev/~name12/+subscriptions also check http://launchpad.dev/~ubuntu-team/+subscriptions for a person with no bug subscriptions.
-- 
https://code.launchpad.net/~brian-murray/launchpad/limited-subscriptions-page/+merge/35177
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~brian-murray/launchpad/limited-subscriptions-page into lp:launchpad/devel.
=== modified file 'lib/lp/registry/browser/configure.zcml'
--- lib/lp/registry/browser/configure.zcml	2010-08-31 10:00:44 +0000
+++ lib/lp/registry/browser/configure.zcml	2010-09-10 22:30:12 +0000
@@ -1031,6 +1031,12 @@
             name="+teamhierarchy"
             template="../templates/person-teamhierarchy.pt"/>
         <browser:page
+            for="lp.registry.interfaces.person.IPerson"
+            permission="zope.Public"
+            class="lp.registry.browser.person.PersonSubscriptionsView"
+            name="+subscriptions"
+            template="../templates/person-subscriptions.pt"/>
+        <browser:page
             for="lp.registry.interfaces.person.ITeam"
             permission="zope.Public"
             class="lp.registry.browser.person.TeamIndexView"

=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py	2010-09-10 12:24:03 +0000
+++ lib/lp/registry/browser/person.py	2010-09-10 22:30:12 +0000
@@ -53,6 +53,7 @@
     'PersonSpecWorkloadView',
     'PersonSpecsMenu',
     'PersonSubscribedBugTaskSearchListingView',
+    'PersonSubscriptionsView',
     'PersonView',
     'PersonVouchersView',
     'RedirectToEditLanguagesView',
@@ -2242,7 +2243,7 @@
         return "Search bugs assigned to %s" % self.context.displayname
 
     def getSimpleSearchURL(self):
-        """Return a URL that can be usedas an href to the simple search."""
+        """Return a URL that can be used as an href to the simple search."""
         return canonical_url(self.context, view_name="+assignedbugs")
 
     @property
@@ -2396,6 +2397,42 @@
         return self.getSearchPageHeading()
 
 
+class PersonSubscriptionsView(BugTaskSearchListingView):
+    """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."""
+        bugtasks = self.context.searchTasks(None, user=self.user,
+                order_by='-date_last_updated',
+                status=(BugTaskStatus.NEW,
+                        BugTaskStatus.INCOMPLETE,
+                        BugTaskStatus.CONFIRMED,
+                        BugTaskStatus.TRIAGED,
+                        BugTaskStatus.INPROGRESS,
+                        BugTaskStatus.FIXCOMMITTED,
+                        BugTaskStatus.FIXRELEASED))
+
+        sub_bugtasks = []
+        sub_bugs = []
+
+        for task in bugtasks:
+            if task.bug not in sub_bugs:
+                sub_bugtasks.append(task)
+                sub_bugs.append(task.bug)
+        return BatchNavigator(sub_bugtasks, self.request)
+
+    def getSubscriptionsPageHeading(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."""
 

=== added file 'lib/lp/registry/stories/person/xx-person-subscriptions.txt'
--- lib/lp/registry/stories/person/xx-person-subscriptions.txt	1970-01-01 00:00:00 +0000
+++ lib/lp/registry/stories/person/xx-person-subscriptions.txt	2010-09-10 22:30:12 +0000
@@ -0,0 +1,56 @@
+Subscriptions View
+==================
+
+Direct bug subscriptions
+
+Each person and team has a subscriptions page that lists things to which they
+are directly subscribed.
+
+    >>> anon_browser.open('http://launchpad.dev/~ubuntu-team/+subscriptions')
+    >>> print anon_browser.title
+    Subscriptions : “Ubuntu Team” team
+
+The bug subscriptions table does not appear for people without any direct bug
+subscriptions.
+
+    >>> page_text = extract_text(find_main_content(anon_browser.contents))
+    >>> "does not have any direct bug subscriptions" in page_text
+    True
+
+The bug subscriptions table does appear for someone with direct bug
+subscriptions and includes the bug number, title and location.
+
+    >>> anon_browser.open('http://launchpad.dev/~name12/+subscriptions')
+    >>> bug_sub_table = find_tag_by_id(
+    ...     anon_browser.contents, 'bug_subscriptions')
+    >>> for tr in bug_sub_table.findAll('tr'):
+    ...     print extract_text(tr)
+    Summary
+    In
+    13
+    Launchpad CSS and JS is not testible
+    Launchpad
+    5
+    Firefox install instructions should be complete
+    mozilla-firefox (Ubuntu Warty)
+    4
+    Reflow problems with complex page layouts
+    Mozilla Firefox
+    2
+    Blackhole Trash folder
+    mozilla-firefox (Debian Woody)
+    9
+    Thunderbird crashes
+    thunderbird (Ubuntu)
+
+
+The bug subscriptions table also includes an unsubscribe link for bugs to
+which the person or team is subscribed.
+
+    >>> browser = setupBrowser(auth='Basic test@xxxxxxxxxxxxx:test')
+    >>> browser.open('http://launchpad.dev/~name12/+subscriptions')
+    >>> unsub_link = browser.getLink(
+    ...     id='unsubscribe-subscriber-12')
+    >>> unsub_link.click()
+    >>> print browser.url
+    http://bugs.launchpad.dev/launchpad/+bug/13/+subscribe

=== added file 'lib/lp/registry/templates/person-subscriptions.pt'
--- lib/lp/registry/templates/person-subscriptions.pt	1970-01-01 00:00:00 +0000
+++ lib/lp/registry/templates/person-subscriptions.pt	2010-09-10 22:30:12 +0000
@@ -0,0 +1,72 @@
+<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"
+>
+  <body>
+
+  <div metal:fill-slot="main"
+    tal:define="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>
+    </tal:no_subscribed_bugs>
+
+    <tal:subscribed_bugs condition="sub_bug_batch|nothing">
+      <p>
+      Bug subscriptions for
+      <tal:person content="context/fmt:displayname">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>
+        </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 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;
+               "
+            >
+              <img src="/@@/remove"
+              tal:attributes="id string:unsubscribe-icon-${context/id};
+                              position string:relative"/>
+            </a>
+          </td>
+      </tr>
+    </table>
+    </tal:subscribed_bugs>
+
+  </div>
+</body>
+</html>