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

Proposed by Gavin Panella on 2010-10-08
Status: Rejected
Rejected by: Gavin Panella on 2010-11-04
Proposed branch: lp:~allenap/launchpad/sub-search-ui-bug-656823
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~allenap/launchpad/wire-up-filter-subs-bug-655567
Diff against target: 239 lines (+88/-83)
2 files modified
lib/lp/registry/browser/person.py (+29/-28)
lib/lp/registry/templates/person-subscriptions.pt (+59/-55)
To merge this branch: bzr merge lp:~allenap/launchpad/sub-search-ui-bug-656823
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code 2010-10-08 Approve on 2010-10-08
Review via email: mp+37976@code.launchpad.net

Commit Message

Various bits and pieces around PersonSubscriptionsView.

Description of the Change

This isn't directly relevant to the bug, but is some stuff I wanted to
do before I begin making bigger changes.

- PersonSubscriptionsView only needs to inherit from LaunchpadView.

- I also simplified it a bit, and added a couple of XXXs to mark out
  some potentially inefficient bits.

- I prettified the +subscriptions template, added lower navigation
  links, fixed it to only display navigation links if there are more
  items than fit on the page, removed an illegal id (a static id in a
  repeated block), and generally tidied up.

This is targeted to db-devel but I may land these changes in devel.

To post a comment you must log in.
Curtis Hovey (sinzui) wrote :

Thanks for this refactoring, the code and template are easier to read.

I see metal:use-macro="view/macro:page/main_side", but this template does not use the side. Is the intent to add navigation to see other listings such as indirect bug subscriptions or blueprints?

(we decided to switch to main_only while discussing it on IRC. It can be changed back to mail_side when the page has side portlets.)

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/person.py'
2--- lib/lp/registry/browser/person.py 2010-10-07 23:49:13 +0000
3+++ lib/lp/registry/browser/person.py 2010-10-08 15:45:58 +0000
4@@ -206,10 +206,6 @@
5 from canonical.launchpad.webapp.login import logoutPerson
6 from canonical.launchpad.webapp.menu import get_current_view
7 from canonical.launchpad.webapp.publisher import LaunchpadView
8-from lp.app.browser.tales import (
9- DateTimeFormatterAPI,
10- PersonFormatterAPI,
11- )
12 from canonical.lazr.utils import smartquote
13 from canonical.widgets import (
14 LaunchpadDropdownWidget,
15@@ -226,6 +222,10 @@
16 from lp.answers.interfaces.questionenums import QuestionParticipation
17 from lp.answers.interfaces.questionsperson import IQuestionsPerson
18 from lp.app.browser.stringformatter import FormattersAPI
19+from lp.app.browser.tales import (
20+ DateTimeFormatterAPI,
21+ PersonFormatterAPI,
22+ )
23 from lp.app.errors import (
24 NotFoundError,
25 UnexpectedFormData,
26@@ -2344,14 +2344,16 @@
27 return self.getSearchPageHeading()
28
29
30-class PersonSubscriptionsView(BugTaskSearchListingView):
31+class PersonSubscriptionsView(LaunchpadView):
32 """All the subscriptions for a person."""
33
34 page_title = 'Subscriptions'
35
36 def subscribedBugTasks(self):
37- """Return a BatchNavigator for distinct bug tasks to which the
38- person is subscribed."""
39+ """
40+ Return a BatchNavigator for distinct bug tasks to which the person is
41+ subscribed.
42+ """
43 bug_tasks = self.context.searchTasks(None, user=self.user,
44 order_by='-date_last_updated',
45 status=(BugTaskStatus.NEW,
46@@ -2364,38 +2366,37 @@
47 bug_subscriber=self.context)
48
49 sub_bug_tasks = []
50- sub_bugs = []
51+ sub_bugs = set()
52
53+ # XXX: GavinPanella 2010-10-08 bug=656904: This materializes the
54+ # entire result set. It would probably be more efficient implemented
55+ # with a pre_iter_hook on a DecoratedResultSet.
56 for task in bug_tasks:
57+ # We order the bugtasks by date_last_updated but we always display
58+ # the default task for the bug. This is to avoid ordering issues
59+ # in tests and also prevents user confusion (because nothing is
60+ # more confusing than your subscription targets changing seemingly
61+ # at random).
62 if task.bug not in sub_bugs:
63- # We order the bugtasks by date_last_updated but we
64- # always display the default task for the bug. This is
65- # to avoid ordering issues in tests and also prevents
66- # user confusion (because nothing is more confusing than
67- # your subscription targets changing seemingly at
68- # random).
69+ # XXX: GavinPanella 2010-10-08 bug=656904: default_bugtask
70+ # causes a query to be executed. It would be more efficient to
71+ # get the default bugtask in bulk, in a pre_iter_hook on a
72+ # DecoratedResultSet perhaps.
73 sub_bug_tasks.append(task.bug.default_bugtask)
74- sub_bugs.append(task.bug)
75+ sub_bugs.add(task.bug)
76+
77 return BatchNavigator(sub_bug_tasks, self.request)
78
79 def canUnsubscribeFromBugTasks(self):
80- viewed_person = self.context
81- if self.user is None:
82- return False
83- elif viewed_person == self.user:
84- return True
85- elif (viewed_person.is_team and
86- self.user.inTeam(viewed_person)):
87- return True
88+ """Can the current user unsubscribe from the bug tasks shown?"""
89+ return (self.user is not None and
90+ self.user.inTeam(self.context))
91
92- def getSubscriptionsPageHeading(self):
93+ @property
94+ def label(self):
95 """The header for the subscriptions page."""
96 return "Subscriptions for %s" % self.context.displayname
97
98- @property
99- def label(self):
100- return self.getSubscriptionsPageHeading()
101-
102
103 class PersonVouchersView(LaunchpadFormView):
104 """Form for displaying and redeeming commercial subscription vouchers."""
105
106=== modified file 'lib/lp/registry/templates/person-subscriptions.pt'
107--- lib/lp/registry/templates/person-subscriptions.pt 2010-09-28 20:55:37 +0000
108+++ lib/lp/registry/templates/person-subscriptions.pt 2010-10-08 15:45:58 +0000
109@@ -1,71 +1,75 @@
110 <html
111- xmlns="http://www.w3.org/1999/xhtml"
112- xmlns:tal="http://xml.zope.org/namespaces/tal"
113- xmlns:metal="http://xml.zope.org/namespaces/metal"
114- xmlns:i18n="http://xml.zope.org/namespaces/i18n"
115- xml:lang="en"
116- lang="en"
117- dir="ltr"
118- metal:use-macro="view/macro:page/main_side"
119- i18n:domain="launchpad"
120->
121+ xmlns="http://www.w3.org/1999/xhtml"
122+ xmlns:tal="http://xml.zope.org/namespaces/tal"
123+ xmlns:metal="http://xml.zope.org/namespaces/metal"
124+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
125+ xml:lang="en"
126+ lang="en"
127+ dir="ltr"
128+ metal:use-macro="view/macro:page/main_only"
129+ i18n:domain="launchpad">
130 <body>
131
132 <div metal:fill-slot="main"
133- tal:define="sub_bugs view/subscribedBugTasks;
134- sub_bug_batch sub_bugs/currentBatch">
135+ tal:define="display_name context/fmt:displayname;
136+ sub_bugs view/subscribedBugTasks;
137+ sub_bug_batch sub_bugs/currentBatch">
138+
139 <tal:no_subscribed_bugs condition="not: sub_bug_batch|nothing">
140- <p><tal:person content="context/fmt:displayname">Sample
141- Person</tal:person> does not have any direct bug subscriptions.</p>
142+ <p>
143+ <tal:person content="display_name">Sample
144+ Person</tal:person> does not have any direct bug subscriptions.
145+ </p>
146 </tal:no_subscribed_bugs>
147
148 <tal:subscribed_bugs condition="sub_bug_batch|nothing">
149 <p>
150- Direct bug subscriptions for
151- <tal:person content="context/fmt:displayname">Sample Person</tal:person>
152+ Direct bug subscriptions for
153+ <tal:person content="display_name">Sample Person</tal:person>
154 </p>
155- <div tal:replace="structure sub_bugs/@@+navigation-links-lower"/>
156- <table id="bug_subscriptions" class="listing">
157- <thead>
158- <tr>
159- <th colspan="3">Summary</th>
160- <th>
161- In
162- </th>
163- <th tal:condition="view/canUnsubscribeFromBugTasks">
164- </th>
165- </tr>
166- </thead>
167- <tr tal:repeat="sub_bug_task sub_bug_batch">
168- <td class="icon left">
169- <span tal:replace="structure sub_bug_task/image:icon" />
170- </td>
171- <td id="bug_number" style="text-align: right">
172- <span tal:replace="sub_bug_task/bug/id" />
173- </td>
174- <td>
175- <a tal:attributes="href sub_bug_task/fmt:url"
176- tal:content="sub_bug_task/bug/title" />
177- </td>
178- <td tal:content="sub_bug_task/bugtargetdisplayname"
179- tal:condition="sub_bug_task/bugtargetdisplayname|nothing"
180- >mozilla-firefox (Ubuntu)</td>
181- <td tal:condition="view/canUnsubscribeFromBugTasks"
182- align="center">
183- <a
184- tal:attributes="
185- title string:Unsubscribe ${context/fmt:displayname} from bug ${sub_bug_task/bug/id};
186- id string:unsubscribe-subscriber-${context/id};
187- href string:${sub_bug_task/fmt:url}/+subscribe;
188- "
189- >
190+ <tal:multipage condition="sub_bugs/has_multiple_pages">
191+ <tal:navigation
192+ replace="structure sub_bugs/@@+navigation-links-upper"/>
193+ </tal:multipage>
194+ <table id="bug_subscriptions" class="listing">
195+ <thead>
196+ <tr>
197+ <th colspan="3">Summary</th>
198+ <th>
199+ In
200+ </th>
201+ <th tal:condition="view/canUnsubscribeFromBugTasks">
202+ </th>
203+ </tr>
204+ </thead>
205+ <tr tal:repeat="sub_bug_task sub_bug_batch">
206+ <td class="icon left">
207+ <span tal:replace="structure sub_bug_task/image:icon" />
208+ </td>
209+ <td style="text-align: right">
210+ <span tal:replace="sub_bug_task/bug/id" />
211+ </td>
212+ <td>
213+ <a tal:attributes="href sub_bug_task/fmt:url"
214+ tal:content="sub_bug_task/bug/title" />
215+ </td>
216+ <td tal:content="sub_bug_task/bugtargetdisplayname"
217+ tal:condition="sub_bug_task/bugtargetdisplayname|nothing" />
218+ <td tal:condition="view/canUnsubscribeFromBugTasks" align="center">
219+ <a tal:attributes="id string:unsubscribe-subscriber-${context/id};
220+ href sub_bug_task/fmt:url/+subscribe;
221+ title string:Unsubscribe ${display_name} from bug ${sub_bug_task/bug/id};">
222 <img src="/@@/edit"
223- tal:attributes="id string:unsubscribe-icon-${context/id};
224- position string:relative"/>
225+ tal:attributes="id string:unsubscribe-icon-${context/id};
226+ position string:relative"/>
227 </a>
228 </td>
229- </tr>
230- </table>
231+ </tr>
232+ </table>
233+ <tal:multipage condition="sub_bugs/has_multiple_pages">
234+ <tal:navigation
235+ replace="structure sub_bugs/@@+navigation-links-lower"/>
236+ </tal:multipage>
237 </tal:subscribed_bugs>
238
239 </div>

Subscribers

People subscribed via source and target branches

to status/vote changes: