Merge lp:~intellectronica/launchpad/sort-by-patch-age into lp:launchpad

Proposed by Eleanor Berger
Status: Merged
Approved by: Eleanor Berger
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~intellectronica/launchpad/sort-by-patch-age
Merge into: lp:launchpad
Prerequisite: lp:~kfogel/launchpad/patches-view-mega-integration
Diff against target: 153 lines (+45/-36)
3 files modified
lib/lp/bugs/browser/bugtarget.py (+5/-5)
lib/lp/bugs/stories/patches-view/patches-view.txt (+35/-30)
lib/lp/bugs/templates/bugtarget-patches.pt (+5/-1)
To merge this branch: bzr merge lp:~intellectronica/launchpad/sort-by-patch-age
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+18531@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Eleanor Berger (intellectronica) wrote :

This branch makes it possible to sort the patch report by patch age, and makes this the default sort order. It also fixes a bug with the validation, where UnexpectedFormData wasn't imported, and adds a test that it works. This branch depends on ~kfogel/launchpad/patches-view-mega-integration - the diff to review is at http://pastebin.ubuntu.com/368253/

Revision history for this message
Henning Eggers (henninge) wrote :

Very nice, thanks for adding this feature.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py 2010-02-03 15:45:31 +0000
+++ lib/lp/bugs/browser/bugtarget.py 2010-02-03 15:45:34 +0000
@@ -62,7 +62,8 @@
62 ITemporaryStorageManager)62 ITemporaryStorageManager)
63from canonical.launchpad.webapp import urlappend63from canonical.launchpad.webapp import urlappend
64from canonical.launchpad.webapp.breadcrumb import Breadcrumb64from canonical.launchpad.webapp.breadcrumb import Breadcrumb
65from canonical.launchpad.webapp.interfaces import ILaunchBag, NotFoundError65from canonical.launchpad.webapp.interfaces import (
66 ILaunchBag, NotFoundError, UnexpectedFormData)
66from lp.bugs.interfaces.bug import (67from lp.bugs.interfaces.bug import (
67 CreateBugParams, IBugAddForm, IProjectBugAddForm)68 CreateBugParams, IBugAddForm, IProjectBugAddForm)
68from lp.bugs.interfaces.malone import IMaloneApplication69from lp.bugs.interfaces.malone import IMaloneApplication
@@ -1406,10 +1407,9 @@
1406 # Zope form instead of validating the values by hand in the1407 # Zope form instead of validating the values by hand in the
1407 # code. Doing it the Zope form way would specify rendering1408 # code. Doing it the Zope form way would specify rendering
1408 # and validation from the same enum, and thus observe DRY.1409 # and validation from the same enum, and thus observe DRY.
1409 orderby = self.request.get("orderby")1410 orderby = self.request.get("orderby", "-latest_patch_uploaded")
1410 if (orderby is not None and1411 if orderby not in ["-latest_patch_uploaded", "-importance", "status",
1411 orderby not in ["-importance", "status", "targetname",1412 "targetname", "datecreated", "-datecreated"]:
1412 "datecreated", "-datecreated"]):
1413 raise UnexpectedFormData(1413 raise UnexpectedFormData(
1414 "Unexpected value for field 'orderby': '%s'" % orderby)1414 "Unexpected value for field 'orderby': '%s'" % orderby)
1415 return BatchNavigator(1415 return BatchNavigator(
14161416
=== modified file 'lib/lp/bugs/stories/patches-view/patches-view.txt'
--- lib/lp/bugs/stories/patches-view/patches-view.txt 2010-02-03 15:45:31 +0000
+++ lib/lp/bugs/stories/patches-view/patches-view.txt 2010-02-03 15:45:34 +0000
@@ -126,22 +126,23 @@
126 ... description="description of patch f", bug=bug_c, is_patch=True)126 ... description="description of patch f", bug=bug_c, is_patch=True)
127 <BugAttachment at...127 <BugAttachment at...
128128
129...the youngest patch on each bug is visible is the patch report.129...the youngest patch on each bug is visible in the patch report.
130130
131 >>> anon_browser.open('http://bugs.launchpad.dev/patchy-product-1/+patches')131 >>> anon_browser.open('http://bugs.launchpad.dev/patchy-product-1/+patches')
132 >>> show_patches_view(anon_browser.contents)132 >>> show_patches_view(anon_browser.contents)
133 Bug Importance Status Patch Age133 Bug Importance Status Patch Age
134 Bug #18: bug_c title Wishlist Fix Committed ...second...
135 From: Patchy Person
136 Link: patch_f.diff description of patch f
134 Bug #17: bug_b title Critical Confirmed ...second...137 Bug #17: bug_b title Critical Confirmed ...second...
135 From: Patchy Person138 From: Patchy Person
136 Link: patch_c.diff description of patch c139 Link: patch_c.diff description of patch c
137 Bug #18: bug_c title Wishlist Fix Committed ...second...
138 From: Patchy Person
139 Link: patch_f.diff description of patch f
140 Bug #16: bug_a title Undecided New ...second...140 Bug #16: bug_a title Undecided New ...second...
141 From: Patchy Person141 From: Patchy Person
142 Link: patch_a.diff description of patch a142 Link: patch_a.diff description of patch a
143143
144We can sort patches by importance and status.144The default sort order is by patch age. We can sort patches by
145importance and status.
145146
146 >>> anon_browser.getControl(name="orderby").value = ['-importance']147 >>> anon_browser.getControl(name="orderby").value = ['-importance']
147 >>> anon_browser.getControl("sort").click()148 >>> anon_browser.getControl("sort").click()
@@ -175,6 +176,14 @@
175 From: Patchy Person176 From: Patchy Person
176 Link: patch_f.diff description of patch f177 Link: patch_f.diff description of patch f
177178
179But we can't sort by things that aren't validated by the view.
180
181 >>> anon_browser.open('http://bugs.launchpad.dev/patchy-product-1/+patches?orderby=star-sign')
182 Traceback (most recent call last):
183 ...
184 UnexpectedFormData: Unexpected value for field 'orderby': 'star-sign'
185
186
178Bugs in a product series show up in the patches view for that series.187Bugs in a product series show up in the patches view for that series.
179188
180 >>> from zope.component import getUtility189 >>> from zope.component import getUtility
@@ -291,14 +300,14 @@
291 Bug #18: bug_c title High Triaged warty ...second...300 Bug #18: bug_c title High Triaged warty ...second...
292 From: Patchy Person301 From: Patchy Person
293 Link: patch_f.diff description of patch f302 Link: patch_f.diff description of patch f
303 Bug #17: bug_b title Undecided New warty ...second...
304 From: Patchy Person
305 Link: patch_c.diff
306 description of patch c
294 Bug #16: bug_a title Undecided New warty ...second...307 Bug #16: bug_a title Undecided New warty ...second...
295 From: Patchy Person308 From: Patchy Person
296 Link: patch_a.diff309 Link: patch_a.diff
297 description of patch a310 description of patch a
298 Bug #17: bug_b title Undecided New warty ...second...
299 From: Patchy Person
300 Link: patch_c.diff
301 description of patch c
302311
303Patches View by Source Package312Patches View by Source Package
304------------------------------313------------------------------
@@ -334,24 +343,20 @@
334 ... 'http://bugs.launchpad.dev/~%s/+patches' % (343 ... 'http://bugs.launchpad.dev/~%s/+patches' % (
335 ... patch_submitter.name,))344 ... patch_submitter.name,))
336 >>> show_patches_view(user_browser.contents)345 >>> show_patches_view(user_browser.contents)
337 Bug Importance Status Patch Age346 Bug Importance Status Patch Age
338 Bug #17: bug_b title Critical Confirmed ...second...347 Bug #18: bug_c title Wishlist Fix Committed ...second...
339 From: Patchy Person348 From: Patchy Person
340 Link: patch_c.diff349 Link: patch_f.diff description of patch f
341 description of patch c350 Bug #18: bug_c title Wishlist Fix Committed ...second...
342 Bug #18: bug_c title High Triaged ...second...351 From: Patchy Person
343 From: Patchy Person352 Link: patch_f.diff description of patch f
344 Link: patch_f.diff353 Bug #18: bug_c title High Triaged ...second...
345 description of patch f354 From: Patchy Person
346 Bug #18: bug_c title High Triaged ...second...355 Link: patch_f.diff description of patch f
347 From: Patchy Person356 Bug #18: bug_c title Undecided New ...second...
348 Link: patch_f.diff357 From: Patchy Person
349 description of patch f358 Link: patch_f.diff description of patch f
350 Bug #16: bug_a title Medium Fix Released ...second...359 Bug #18: bug_c title High Triaged ...second...
351 From: Patchy Person360 From: Patchy Person
352 Link: patch_a.diff361 Link: patch_f.diff description of patch f
353 description of patch a362
354 Bug #18: bug_c title Wishlist Fix Committed ...second...
355 From: Patchy Person
356 Link: patch_f.diff
357 description of patch f
358363
=== modified file 'lib/lp/bugs/templates/bugtarget-patches.pt'
--- lib/lp/bugs/templates/bugtarget-patches.pt 2010-02-03 15:45:31 +0000
+++ lib/lp/bugs/templates/bugtarget-patches.pt 2010-02-03 15:45:34 +0000
@@ -32,7 +32,11 @@
3232
33 Order&nbsp;by:&nbsp;<select33 Order&nbsp;by:&nbsp;<select
34 name="orderby" id="orderby" size="1"34 name="orderby" id="orderby" size="1"
35 tal:define="orderby request/orderby|string:-importance">35 tal:define="orderby request/orderby|string:-latest_patch_uploaded">
36 <option
37 value="-latest_patch_uploaded"
38 tal:attributes="selected python:orderby == '-latest_patch_uploaded'"
39 >patch age</option>
36 <option40 <option
37 value="-importance"41 value="-importance"
38 tal:attributes="selected python:orderby == '-importance'"42 tal:attributes="selected python:orderby == '-importance'"