Merge lp:~cjwatson/launchpad/bugtask-sorted-milestones into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17843
Proposed branch: lp:~cjwatson/launchpad/bugtask-sorted-milestones
Merge into: lp:launchpad
Diff against target: 77 lines (+24/-5)
3 files modified
lib/lp/bugs/stories/bugtask-management/xx-change-milestone.txt (+3/-2)
lib/lp/bugs/tests/test_vocabulary.py (+14/-1)
lib/lp/bugs/vocabularies.py (+7/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/bugtask-sorted-milestones
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+276435@code.launchpad.net

Commit message

Use standard milestone ordering for bug task milestone choices.

Description of the change

Use standard milestone ordering for bug task milestone choices. Unsorted listings aren't very friendly.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
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/stories/bugtask-management/xx-change-milestone.txt'
2--- lib/lp/bugs/stories/bugtask-management/xx-change-milestone.txt 2013-04-11 00:51:46 +0000
3+++ lib/lp/bugs/stories/bugtask-management/xx-change-milestone.txt 2015-11-02 17:54:03 +0000
4@@ -1,4 +1,5 @@
5-= Changing Milestones of Bugtasks =
6+Changing Milestones of Bugtasks
7+===============================
8
9 Bugtasks associated with products, productseries, distributions and
10 distroseries can be targeted to milestones.
11@@ -62,7 +63,7 @@
12 >>> milestone_control.displayValue
13 ['(nothing selected)']
14 >>> milestone_control.displayOptions
15- ['(nothing selected)', 'Mozilla Firefox 1.0', 'Mozilla Firefox 1.0.1']
16+ ['(nothing selected)', 'Mozilla Firefox 1.0.1', 'Mozilla Firefox 1.0']
17 >>> milestone_control.displayValue = ['Mozilla Firefox 1.0.1']
18 >>> owner_browser.getControl('Save Changes', index=1).click()
19 >>> milestone_control = owner_browser.getControl(
20
21=== modified file 'lib/lp/bugs/tests/test_vocabulary.py'
22--- lib/lp/bugs/tests/test_vocabulary.py 2012-10-15 02:32:30 +0000
23+++ lib/lp/bugs/tests/test_vocabulary.py 2015-11-02 17:54:03 +0000
24@@ -1,4 +1,4 @@
25-# Copyright 2011 Canonical Ltd. This software is licensed under the
26+# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
27 # GNU Affero General Public License version 3 (see the file LICENSE).
28
29 """Test the bug domain vocabularies."""
30@@ -133,3 +133,16 @@
31 sourcepackage = self.factory.makeSourcePackage(
32 distroseries=distroseries)
33 self._assert_milestones(sourcepackage, milestone)
34+
35+ def test_sorted(self):
36+ product = self.factory.makeProduct()
37+ milestone1 = self.factory.makeMilestone(product=product, name="1.0.0")
38+ milestone2 = self.factory.makeMilestone(product=product, name="1.10.0")
39+ milestone3 = self.factory.makeMilestone(product=product, name="1.6.2")
40+ milestone4 = self.factory.makeMilestone(product=product, name="1.8.4")
41+ bugtask = self.factory.makeBugTask(target=product)
42+ vocabulary = BugTaskMilestoneVocabulary(bugtask)
43+ self.assertEqual(
44+ [milestone2.displayname, milestone4.displayname,
45+ milestone3.displayname, milestone1.displayname],
46+ [term.title for term in vocabulary])
47
48=== modified file 'lib/lp/bugs/vocabularies.py'
49--- lib/lp/bugs/vocabularies.py 2015-10-13 13:22:08 +0000
50+++ lib/lp/bugs/vocabularies.py 2015-11-02 17:54:03 +0000
51@@ -1,4 +1,4 @@
52-# Copyright 2011 Canonical Ltd. This software is licensed under the
53+# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
54 # GNU Affero General Public License version 3 (see the file LICENSE).
55
56 """Bug domain vocabularies"""
57@@ -61,6 +61,7 @@
58 from lp.registry.interfaces.sourcepackage import ISourcePackage
59 from lp.registry.model.distribution import Distribution
60 from lp.registry.model.distroseries import DistroSeries
61+from lp.registry.model.milestone import milestone_sort_key
62 from lp.registry.model.productseries import ProductSeries
63 from lp.registry.vocabularies import DistributionVocabulary
64 from lp.services.database.interfaces import IStore
65@@ -393,7 +394,11 @@
66 # linked to it. Include such milestones in the vocabulary to
67 # ensure that the +editstatus page doesn't break.
68 milestones.append(bugtask.milestone)
69- return milestones
70+
71+ def naked_milestone_sort_key(milestone):
72+ return milestone_sort_key(removeSecurityProxy(milestone))
73+
74+ return sorted(milestones, key=naked_milestone_sort_key, reverse=True)
75
76 def getTerm(self, value):
77 """See `IVocabulary`."""