← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~replaceafill/launchpad/bug-260677 into lp:launchpad

 

Douglas Cerna has proposed merging lp:~replaceafill/launchpad/bug-260677 into lp:launchpad.

Requested reviews:
  William Grant (wgrant)
Related bugs:
  Bug #260677 in Launchpad itself: "Include date with milestones on advanced search page"
  https://bugs.launchpad.net/launchpad/+bug/260677

For more details, see:
https://code.launchpad.net/~replaceafill/launchpad/bug-260677/+merge/200371

Dates expected are now shown for milestones in the advanced bugs search page.
-- 
https://code.launchpad.net/~replaceafill/launchpad/bug-260677/+merge/200371
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py	2013-04-10 08:35:47 +0000
+++ lib/lp/bugs/browser/bugtask.py	2014-01-03 07:47:33 +0000
@@ -3057,7 +3057,7 @@
 
     def getMilestoneWidgetValues(self):
         """Return data used to render the milestone checkboxes."""
-        return self.getWidgetValues("Milestone")
+        return self.getWidgetValues("MilestoneWithDateExpected")
 
     def getSimpleSearchURL(self):
         """Return a URL that can be used as an href to the simple search."""

=== modified file 'lib/lp/bugs/browser/tests/bugtask-search-views.txt'
--- lib/lp/bugs/browser/tests/bugtask-search-views.txt	2012-12-10 13:43:47 +0000
+++ lib/lp/bugs/browser/tests/bugtask-search-views.txt	2014-01-03 07:47:33 +0000
@@ -68,8 +68,8 @@
     ...     distro_advanced_search_listingview.getMilestoneWidgetValues())
     >>> for value in milestones:
     ...     print value['title']
-    Debian 3.1
-    Debian 3.1-rc1
+    Debian 3.1 (2056-05-16)
+    Debian 3.1-rc1 (2056-02-16)
 
 The same milestone will be available for a debian package.
 
@@ -82,8 +82,8 @@
     ...     package_advanced_search_listingview.getMilestoneWidgetValues())
     >>> for value in milestones:
     ...     print value['title']
-    Debian 3.1
-    Debian 3.1-rc1
+    Debian 3.1 (2056-05-16)
+    Debian 3.1-rc1 (2056-02-16)
 
 A triager may find it useful to query for bugs with no package:
 
@@ -349,7 +349,7 @@
     ...     mozilla, '+bugs', form_values)
     >>> for value in advanced_search_view.getMilestoneWidgetValues():
     ...     print value['title']
-    Mozilla Firefox 1.0
+    Mozilla Firefox 1.0 (2056-10-16)
 
 
 == Searching by information type ==

=== modified file 'lib/lp/registry/tests/test_milestone_vocabularies.py'
--- lib/lp/registry/tests/test_milestone_vocabularies.py	2012-11-16 14:07:39 +0000
+++ lib/lp/registry/tests/test_milestone_vocabularies.py	2014-01-03 07:47:33 +0000
@@ -13,7 +13,10 @@
 from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.product import IProductSet
 from lp.registry.interfaces.projectgroup import IProjectGroupSet
-from lp.registry.vocabularies import MilestoneVocabulary
+from lp.registry.vocabularies import (
+    MilestoneVocabulary,
+    MilestoneWithDateExpectedVocabulary,
+    )
 from lp.testing import (
     login,
     logout,
@@ -116,3 +119,31 @@
         self.assertEqual(
             [term.title for term in vocabulary],
             [u'Debian 3.1', u'Debian 3.1-rc1', u'Mozilla Firefox 1.0'])
+
+
+class TestMilestoneWithDateExpectedVocabulary(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def setUp(self):
+        super(TestMilestoneWithDateExpectedVocabulary, self).setUp()
+        login('test@xxxxxxxxxxxxx')
+
+    def tearDown(self):
+        super(TestMilestoneWithDateExpectedVocabulary, self).tearDown()
+        logout()
+
+    def test_milestone_with_date_expected(self):
+        firefox = getUtility(IProductSet).getByName('firefox')
+        vocabulary = MilestoneWithDateExpectedVocabulary(firefox)
+        self.assertEqual(
+            [term.title for term in vocabulary],
+            [u'Mozilla Firefox 1.0 (2056-10-16)'])
+
+    def test_milestone_without_date_expected(self):
+        evolution = getUtility(IProductSet).getByName('evolution')
+        series = evolution.getSeries('trunk')
+        series.newMilestone(name='3.0', dateexpected=None)
+        vocabulary = MilestoneWithDateExpectedVocabulary(evolution)
+        self.assertEqual(
+            [term.title for term in vocabulary], ['Evolution 3.0'])

=== modified file 'lib/lp/registry/vocabularies.py'
--- lib/lp/registry/vocabularies.py	2013-06-20 05:50:00 +0000
+++ lib/lp/registry/vocabularies.py	2014-01-03 07:47:33 +0000
@@ -40,6 +40,7 @@
     'FilteredProductSeriesVocabulary',
     'KarmaCategoryVocabulary',
     'MilestoneVocabulary',
+    'MilestoneWithDateExpectedVocabulary',
     'NewPillarGranteeVocabulary',
     'NonMergedPeopleAndTeamsVocabulary',
     'person_team_participations_vocabulary_factory',
@@ -95,6 +96,7 @@
 
 from lp.blueprints.interfaces.specification import ISpecification
 from lp.code.interfaces.branch import IBranch
+from lp.app.browser.tales import DateTimeFormatterAPI
 from lp.registry.enums import (
     EXCLUSIVE_TEAM_POLICY,
     PersonVisibility,
@@ -1386,6 +1388,17 @@
             return SQLObjectVocabularyBase.__contains__(self, obj)
 
 
+class MilestoneWithDateExpectedVocabulary(MilestoneVocabulary):
+
+    def toTerm(self, obj):
+        """See `IVocabulary`."""
+        term = super(MilestoneWithDateExpectedVocabulary, self).toTerm(obj)
+        if obj.dateexpected:
+            formatter = DateTimeFormatterAPI(obj.dateexpected)
+            term.title += ' (%s)' % formatter.approximatedate()
+        return term
+
+
 class CommercialProjectsVocabulary(NamedSQLObjectVocabulary):
     """List all commercial projects.
 

=== modified file 'lib/lp/registry/vocabularies.zcml'
--- lib/lp/registry/vocabularies.zcml	2012-10-04 23:15:35 +0000
+++ lib/lp/registry/vocabularies.zcml	2014-01-03 07:47:33 +0000
@@ -119,6 +119,19 @@
 
 
   <securedutility
+    name="MilestoneWithDateExpected"
+    component="lp.registry.vocabularies.MilestoneWithDateExpectedVocabulary"
+    provides="zope.schema.interfaces.IVocabularyFactory"
+    >
+    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
+  </securedutility>
+
+  <class class="lp.registry.vocabularies.MilestoneWithDateExpectedVocabulary">
+    <allow interface="lp.services.webapp.vocabulary.IHugeVocabulary"/>
+  </class>
+
+
+  <securedutility
     name="NonMergedPeopleAndTeams"
     component="lp.registry.vocabularies.NonMergedPeopleAndTeamsVocabulary"
     provides="zope.schema.interfaces.IVocabularyFactory"


Follow ups