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
1=== modified file 'lib/lp/bugs/browser/bugtarget.py'
2--- lib/lp/bugs/browser/bugtarget.py 2010-02-03 15:45:31 +0000
3+++ lib/lp/bugs/browser/bugtarget.py 2010-02-03 15:45:34 +0000
4@@ -62,7 +62,8 @@
5 ITemporaryStorageManager)
6 from canonical.launchpad.webapp import urlappend
7 from canonical.launchpad.webapp.breadcrumb import Breadcrumb
8-from canonical.launchpad.webapp.interfaces import ILaunchBag, NotFoundError
9+from canonical.launchpad.webapp.interfaces import (
10+ ILaunchBag, NotFoundError, UnexpectedFormData)
11 from lp.bugs.interfaces.bug import (
12 CreateBugParams, IBugAddForm, IProjectBugAddForm)
13 from lp.bugs.interfaces.malone import IMaloneApplication
14@@ -1406,10 +1407,9 @@
15 # Zope form instead of validating the values by hand in the
16 # code. Doing it the Zope form way would specify rendering
17 # and validation from the same enum, and thus observe DRY.
18- orderby = self.request.get("orderby")
19- if (orderby is not None and
20- orderby not in ["-importance", "status", "targetname",
21- "datecreated", "-datecreated"]):
22+ orderby = self.request.get("orderby", "-latest_patch_uploaded")
23+ if orderby not in ["-latest_patch_uploaded", "-importance", "status",
24+ "targetname", "datecreated", "-datecreated"]:
25 raise UnexpectedFormData(
26 "Unexpected value for field 'orderby': '%s'" % orderby)
27 return BatchNavigator(
28
29=== modified file 'lib/lp/bugs/stories/patches-view/patches-view.txt'
30--- lib/lp/bugs/stories/patches-view/patches-view.txt 2010-02-03 15:45:31 +0000
31+++ lib/lp/bugs/stories/patches-view/patches-view.txt 2010-02-03 15:45:34 +0000
32@@ -126,22 +126,23 @@
33 ... description="description of patch f", bug=bug_c, is_patch=True)
34 <BugAttachment at...
35
36-...the youngest patch on each bug is visible is the patch report.
37+...the youngest patch on each bug is visible in the patch report.
38
39 >>> anon_browser.open('http://bugs.launchpad.dev/patchy-product-1/+patches')
40 >>> show_patches_view(anon_browser.contents)
41 Bug Importance Status Patch Age
42+ Bug #18: bug_c title Wishlist Fix Committed ...second...
43+ From: Patchy Person
44+ Link: patch_f.diff description of patch f
45 Bug #17: bug_b title Critical Confirmed ...second...
46 From: Patchy Person
47 Link: patch_c.diff description of patch c
48- Bug #18: bug_c title Wishlist Fix Committed ...second...
49- From: Patchy Person
50- Link: patch_f.diff description of patch f
51 Bug #16: bug_a title Undecided New ...second...
52 From: Patchy Person
53 Link: patch_a.diff description of patch a
54
55-We can sort patches by importance and status.
56+The default sort order is by patch age. We can sort patches by
57+importance and status.
58
59 >>> anon_browser.getControl(name="orderby").value = ['-importance']
60 >>> anon_browser.getControl("sort").click()
61@@ -175,6 +176,14 @@
62 From: Patchy Person
63 Link: patch_f.diff description of patch f
64
65+But we can't sort by things that aren't validated by the view.
66+
67+ >>> anon_browser.open('http://bugs.launchpad.dev/patchy-product-1/+patches?orderby=star-sign')
68+ Traceback (most recent call last):
69+ ...
70+ UnexpectedFormData: Unexpected value for field 'orderby': 'star-sign'
71+
72+
73 Bugs in a product series show up in the patches view for that series.
74
75 >>> from zope.component import getUtility
76@@ -291,14 +300,14 @@
77 Bug #18: bug_c title High Triaged warty ...second...
78 From: Patchy Person
79 Link: patch_f.diff description of patch f
80+ Bug #17: bug_b title Undecided New warty ...second...
81+ From: Patchy Person
82+ Link: patch_c.diff
83+ description of patch c
84 Bug #16: bug_a title Undecided New warty ...second...
85 From: Patchy Person
86 Link: patch_a.diff
87 description of patch a
88- Bug #17: bug_b title Undecided New warty ...second...
89- From: Patchy Person
90- Link: patch_c.diff
91- description of patch c
92
93 Patches View by Source Package
94 ------------------------------
95@@ -334,24 +343,20 @@
96 ... 'http://bugs.launchpad.dev/~%s/+patches' % (
97 ... patch_submitter.name,))
98 >>> show_patches_view(user_browser.contents)
99- Bug Importance Status Patch Age
100- Bug #17: bug_b title Critical Confirmed ...second...
101- From: Patchy Person
102- Link: patch_c.diff
103- description of patch c
104- Bug #18: bug_c title High Triaged ...second...
105- From: Patchy Person
106- Link: patch_f.diff
107- description of patch f
108- Bug #18: bug_c title High Triaged ...second...
109- From: Patchy Person
110- Link: patch_f.diff
111- description of patch f
112- Bug #16: bug_a title Medium Fix Released ...second...
113- From: Patchy Person
114- Link: patch_a.diff
115- description of patch a
116- Bug #18: bug_c title Wishlist Fix Committed ...second...
117- From: Patchy Person
118- Link: patch_f.diff
119- description of patch f
120+ Bug Importance Status Patch Age
121+ Bug #18: bug_c title Wishlist Fix Committed ...second...
122+ From: Patchy Person
123+ Link: patch_f.diff description of patch f
124+ Bug #18: bug_c title Wishlist Fix Committed ...second...
125+ From: Patchy Person
126+ Link: patch_f.diff description of patch f
127+ Bug #18: bug_c title High Triaged ...second...
128+ From: Patchy Person
129+ Link: patch_f.diff description of patch f
130+ Bug #18: bug_c title Undecided New ...second...
131+ From: Patchy Person
132+ Link: patch_f.diff description of patch f
133+ Bug #18: bug_c title High Triaged ...second...
134+ From: Patchy Person
135+ Link: patch_f.diff description of patch f
136+
137
138=== modified file 'lib/lp/bugs/templates/bugtarget-patches.pt'
139--- lib/lp/bugs/templates/bugtarget-patches.pt 2010-02-03 15:45:31 +0000
140+++ lib/lp/bugs/templates/bugtarget-patches.pt 2010-02-03 15:45:34 +0000
141@@ -32,7 +32,11 @@
142
143 Order&nbsp;by:&nbsp;<select
144 name="orderby" id="orderby" size="1"
145- tal:define="orderby request/orderby|string:-importance">
146+ tal:define="orderby request/orderby|string:-latest_patch_uploaded">
147+ <option
148+ value="-latest_patch_uploaded"
149+ tal:attributes="selected python:orderby == '-latest_patch_uploaded'"
150+ >patch age</option>
151 <option
152 value="-importance"
153 tal:attributes="selected python:orderby == '-importance'"