Merge lp:~stevenk/launchpad/branch-approximatedate into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 13343
Proposed branch: lp:~stevenk/launchpad/branch-approximatedate
Merge into: lp:launchpad
Diff against target: 103 lines (+12/-21)
4 files modified
lib/lp/code/browser/branchlisting.py (+0/-10)
lib/lp/code/browser/tests/test_branchlisting.py (+7/-6)
lib/lp/code/templates/branch-listing.pt (+4/-4)
lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt (+1/-1)
To merge this branch: bzr merge lp:~stevenk/launchpad/branch-approximatedate
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+66480@code.launchpad.net

Commit message

[r=lifeless][bug=162305] Use approximatedate for showing branch dates.

Description of the change

Change how dates for branches are displayed. This took far too long to sort out, but there are two properties in branchlisting called since_created and since_updated. They return a duration which was then formatted as a duration -- and the duration formatter maxed out at weeks, so branches would show 'Last modified: 163 weeks ago'.

I have ripped them out, and switched to the dates themselves, which will show approximate dates, such as 'Last modified: 2 years ago'.

I have written a sinfully small test for this, but approximatedate is very well tested.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/branchlisting.py'
2--- lib/lp/code/browser/branchlisting.py 2011-06-27 15:14:46 +0000
3+++ lib/lp/code/browser/branchlisting.py 2011-06-30 21:43:40 +0000
4@@ -216,16 +216,6 @@
5 return [series for series in self.associated_product_series
6 if series.status != SeriesStatus.OBSOLETE]
7
8- @property
9- def since_updated(self):
10- """How long since the branch was last updated."""
11- return self._now - self.context.date_last_modified
12-
13- @property
14- def since_created(self):
15- """How long since the branch was created."""
16- return self._now - self.context.date_created
17-
18 def isBugBadgeVisible(self):
19 return self.show_bug_badge
20
21
22=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
23--- lib/lp/code/browser/tests/test_branchlisting.py 2011-06-02 20:53:43 +0000
24+++ lib/lp/code/browser/tests/test_branchlisting.py 2011-06-30 21:43:40 +0000
25@@ -8,7 +8,6 @@
26 from datetime import timedelta
27 from pprint import pformat
28 import re
29-import unittest
30
31 from lazr.uri import URI
32 from storm.expr import (
33@@ -422,6 +421,12 @@
34 # portlet isn't shown.
35 self.assertIs(None, branches)
36
37+ def test_branch_listing_last_modified(self):
38+ branch = self.factory.makeProductBranch()
39+ view = create_initialized_view(
40+ branch.product, name="+branches", rootsite='code')
41+ self.assertIn('a moment ago', view())
42+
43
44 class TestProjectGroupBranches(TestCaseWithFactory):
45 """Test for the project group branches page."""
46@@ -429,7 +434,7 @@
47 layer = DatabaseFunctionalLayer
48
49 def setUp(self):
50- TestCaseWithFactory.setUp(self)
51+ super(TestProjectGroupBranches, self).setUp()
52 self.project = self.factory.makeProject()
53
54 def test_project_with_no_branch_visibility_rule(self):
55@@ -509,7 +514,3 @@
56 self.project, name='+branches', rootsite='code')
57 table = find_tag_by_id(view(), "branchtable")
58 self.assertIsNot(None, table)
59-
60-
61-def test_suite():
62- return unittest.TestLoader().loadTestsFromName(__name__)
63
64=== modified file 'lib/lp/code/templates/branch-listing.pt'
65--- lib/lp/code/templates/branch-listing.pt 2011-02-09 00:29:50 +0000
66+++ lib/lp/code/templates/branch-listing.pt 2011-06-30 21:43:40 +0000
67@@ -119,9 +119,9 @@
68 2005-02-12 13:45 EST
69 </span>
70 <span tal:attributes="title branch/date_created/fmt:datetime"
71- tal:content="branch/since_created/fmt:approximateduration/use-digits">
72+ tal:content="branch/date_created/fmt:approximatedate">
73 sometime
74- </span> ago
75+ </span>
76 </td>
77 <td tal:condition="context/show_column/product|nothing">
78 <a tal:condition="branch/product"
79@@ -137,9 +137,9 @@
80 2005-02-12 13:45 EST
81 </span>
82 <span tal:attributes="title branch/date_last_modified/fmt:datetime"
83- tal:content="branch/since_updated/fmt:approximateduration/use-digits">
84+ tal:content="branch/date_last_modified/fmt:approximatedate">
85 sometime
86- </span> ago
87+ </span>
88 </td>
89
90 <tal:no_commit condition="not: branch/last_commit">
91
92=== modified file 'lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt'
93--- lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt 2011-06-29 15:06:32 +0000
94+++ lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt 2011-06-30 21:43:40 +0000
95@@ -69,7 +69,7 @@
96 </td>
97 <td>
98 <span tal:attributes="title branch/date_last_modified/fmt:datetime"
99- tal:content="branch/since_updated/fmt:approximateduration/use-digits">
100+ tal:content="branch/date_last_updated/fmt:approximatedate">
101 sometime
102 </span> ago
103 </td>