launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19696
[Merge] lp:~cjwatson/launchpad/bugtask-sorted-milestones into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/bugtask-sorted-milestones into lp:launchpad.
Commit message:
Use standard milestone ordering for bug task milestone choices.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1512213 in Launchpad itself: "Milestone list in random order"
https://bugs.launchpad.net/launchpad/+bug/1512213
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/bugtask-sorted-milestones/+merge/276435
Use standard milestone ordering for bug task milestone choices. Unsorted listings aren't very friendly.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bugtask-sorted-milestones into lp:launchpad.
=== modified file 'lib/lp/bugs/stories/bugtask-management/xx-change-milestone.txt'
--- lib/lp/bugs/stories/bugtask-management/xx-change-milestone.txt 2013-04-11 00:51:46 +0000
+++ lib/lp/bugs/stories/bugtask-management/xx-change-milestone.txt 2015-11-02 17:54:03 +0000
@@ -1,4 +1,5 @@
-= Changing Milestones of Bugtasks =
+Changing Milestones of Bugtasks
+===============================
Bugtasks associated with products, productseries, distributions and
distroseries can be targeted to milestones.
@@ -62,7 +63,7 @@
>>> milestone_control.displayValue
['(nothing selected)']
>>> milestone_control.displayOptions
- ['(nothing selected)', 'Mozilla Firefox 1.0', 'Mozilla Firefox 1.0.1']
+ ['(nothing selected)', 'Mozilla Firefox 1.0.1', 'Mozilla Firefox 1.0']
>>> milestone_control.displayValue = ['Mozilla Firefox 1.0.1']
>>> owner_browser.getControl('Save Changes', index=1).click()
>>> milestone_control = owner_browser.getControl(
=== modified file 'lib/lp/bugs/tests/test_vocabulary.py'
--- lib/lp/bugs/tests/test_vocabulary.py 2012-10-15 02:32:30 +0000
+++ lib/lp/bugs/tests/test_vocabulary.py 2015-11-02 17:54:03 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011 Canonical Ltd. This software is licensed under the
+# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test the bug domain vocabularies."""
@@ -133,3 +133,16 @@
sourcepackage = self.factory.makeSourcePackage(
distroseries=distroseries)
self._assert_milestones(sourcepackage, milestone)
+
+ def test_sorted(self):
+ product = self.factory.makeProduct()
+ milestone1 = self.factory.makeMilestone(product=product, name="1.0.0")
+ milestone2 = self.factory.makeMilestone(product=product, name="1.10.0")
+ milestone3 = self.factory.makeMilestone(product=product, name="1.6.2")
+ milestone4 = self.factory.makeMilestone(product=product, name="1.8.4")
+ bugtask = self.factory.makeBugTask(target=product)
+ vocabulary = BugTaskMilestoneVocabulary(bugtask)
+ self.assertEqual(
+ [milestone2.displayname, milestone4.displayname,
+ milestone3.displayname, milestone1.displayname],
+ [term.title for term in vocabulary])
=== modified file 'lib/lp/bugs/vocabularies.py'
--- lib/lp/bugs/vocabularies.py 2015-10-13 13:22:08 +0000
+++ lib/lp/bugs/vocabularies.py 2015-11-02 17:54:03 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011 Canonical Ltd. This software is licensed under the
+# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Bug domain vocabularies"""
@@ -61,6 +61,7 @@
from lp.registry.interfaces.sourcepackage import ISourcePackage
from lp.registry.model.distribution import Distribution
from lp.registry.model.distroseries import DistroSeries
+from lp.registry.model.milestone import milestone_sort_key
from lp.registry.model.productseries import ProductSeries
from lp.registry.vocabularies import DistributionVocabulary
from lp.services.database.interfaces import IStore
@@ -393,7 +394,11 @@
# linked to it. Include such milestones in the vocabulary to
# ensure that the +editstatus page doesn't break.
milestones.append(bugtask.milestone)
- return milestones
+
+ def naked_milestone_sort_key(milestone):
+ return milestone_sort_key(removeSecurityProxy(milestone))
+
+ return sorted(milestones, key=naked_milestone_sort_key, reverse=True)
def getTerm(self, value):
"""See `IVocabulary`."""
Follow ups