Merge lp:~beuno/wikkid/show-last-person-to-change into lp:wikkid

Proposed by Martin Albisetti
Status: Merged
Merged at revision: 42
Proposed branch: lp:~beuno/wikkid/show-last-person-to-change
Merge into: lp:wikkid
Diff against target: 139 lines (+55/-6)
7 files modified
wikkid/filestore/bzr.py (+7/-0)
wikkid/skin/default/base.html (+1/-3)
wikkid/skin/default/page.html (+6/-1)
wikkid/skin/default/static/default.css (+1/-1)
wikkid/tests/views/test_edit.py (+1/-1)
wikkid/tests/views/test_view.py (+29/-0)
wikkid/view/wiki.py (+10/-0)
To merge this branch: bzr merge lp:~beuno/wikkid/show-last-person-to-change
Reviewer Review Type Date Requested Status
Tim Penhey Approve
Review via email: mp+26890@code.launchpad.net

Description of the change

This shows the last person who changed a page and the date.

This branch has a disabled test, from what I could see from 30.000 feet with turbulence, the tests don't actually commit any changes, they just mock it. I'm not sure how to make it work so I left it there but disabled.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Accepted with some tweaks.

review: Approve
Revision history for this message
Tim Penhey (thumper) wrote :

I added last_modified_date and last_modified_by into the model interface as well.

last_modified_date now returns a datetime object naive but in UTC.

the last_modified_by from the model returns a user object.

Revision history for this message
Tim Penhey (thumper) wrote :

Volatile filestore was updated to remember last_modified_by and last_modified_date.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'wikkid/filestore/bzr.py'
2--- wikkid/filestore/bzr.py 2010-06-01 08:34:44 +0000
3+++ wikkid/filestore/bzr.py 2010-06-06 22:32:26 +0000
4@@ -247,6 +247,13 @@
5 return rev.get_apparent_authors()[0]
6
7 @property
8+ def last_modified_date(self):
9+ """Return the last modified date for the revision."""
10+ repo = self.working_tree.branch.repository
11+ rev = repo.get_revision(self.last_modified_in_revision)
12+ return rev.timestamp
13+
14+ @property
15 def _is_binary(self):
16 """True if the file is binary."""
17 try:
18
19=== modified file 'wikkid/skin/default/base.html'
20--- wikkid/skin/default/base.html 2010-05-22 20:21:33 +0000
21+++ wikkid/skin/default/base.html 2010-06-06 22:32:26 +0000
22@@ -41,9 +41,7 @@
23 <div id="main">
24 {% block content %}{% endblock %}
25 </div>
26-<!--
27- <p class="last-edit">Last edited by Foo Bar on Apr 1st, 2010 (<a href="#" title="View log">view log</a>)</p>
28--->
29+ {% block footer %}{% endblock %}
30 <div id="footer">
31 &copy; 2010
32 <a href="https://launchpad.net/~wikkid">Wikkid Developers</a>,
33
34=== modified file 'wikkid/skin/default/page.html'
35--- wikkid/skin/default/page.html 2010-05-06 08:37:10 +0000
36+++ wikkid/skin/default/page.html 2010-06-06 22:32:26 +0000
37@@ -1,9 +1,14 @@
38 {% extends "base.html" %}
39 {% block title %}{{ view.title }}{% endblock %}
40-{% block content %}{{ view.content }}{% endblock %}
41+{% block content %}{{ view.content }}
42+{% endblock %}
43 {% block commands %}
44 {% if view.user %}
45 <a class="command" href="{{view.request_path}}?view=edit">Edit</a>
46 <a class="command" href="{{context.dir_name}}?view=listing">Browse</a>
47 {% endif %}
48 {% endblock %}
49+{% block footer %}
50+<p class="last-edit">Last edited by <strong>{{ view.last_modified_by }}</strong>
51+ on {{ view.last_modified_date }}</p>
52+{% endblock %}
53
54=== modified file 'wikkid/skin/default/static/default.css'
55--- wikkid/skin/default/static/default.css 2010-05-31 12:45:14 +0000
56+++ wikkid/skin/default/static/default.css 2010-06-06 22:32:26 +0000
57@@ -127,7 +127,7 @@
58 line-height: 1.4em;
59 }
60 p.last-edit {
61- font-size: 0.8em;
62+ font-size: 0.6em;
63 margin-left: 1em;
64 }
65 ul, ol, dl {
66
67=== modified file 'wikkid/tests/views/test_edit.py'
68--- wikkid/tests/views/test_edit.py 2010-06-01 08:47:24 +0000
69+++ wikkid/tests/views/test_edit.py 2010-06-06 22:32:26 +0000
70@@ -19,7 +19,7 @@
71 self.user = TestUser('test@example.com', 'Test User')
72 self.request = TestRequest()
73
74- def test_title_nexted(self):
75+ def test_title_nested(self):
76 """Test that a nested page returns the expected title"""
77 factory = self.make_factory([
78 ('SomePage/SubPage/Nested.txt', 'some text')])
79
80=== added file 'wikkid/tests/views/test_view.py'
81--- wikkid/tests/views/test_view.py 1970-01-01 00:00:00 +0000
82+++ wikkid/tests/views/test_view.py 2010-06-06 22:32:26 +0000
83@@ -0,0 +1,29 @@
84+#
85+# Copyright (C) 2010 Wikkid Developers.
86+#
87+# This software is licensed under the GNU Affero General Public License
88+# version 3 (see the file LICENSE).
89+
90+"""Tests the display views."""
91+
92+from wikkid.dispatcher import get_view
93+from wikkid.tests.factory import FactoryTestCase
94+from wikkid.tests.fakes import TestRequest, TestUser
95+
96+#XXX: This test fails, it seems to not actually commit, may need more faking
97+class DisabledTestView(FactoryTestCase):
98+ """Test the display view."""
99+
100+ def setUp(self):
101+ super(TestView, self).setUp()
102+ self.user = TestUser('test@example.com', 'Test User')
103+ self.request = TestRequest()
104+
105+ def test_last_modified_by(self):
106+ """Test that the last committer is displayed properly"""
107+ factory = self.make_factory([
108+ ('SomePage/SubPage/Nested.txt', 'some text')])
109+ info = factory.get_resource_at_path('/SomePage/SubPage/Nested.txt')
110+ view = get_view(info, 'view', self.request, self.user)
111+ self.assertEqual('Test User', view.last_modified_by)
112+
113
114=== modified file 'wikkid/view/wiki.py'
115--- wikkid/view/wiki.py 2010-05-16 04:03:04 +0000
116+++ wikkid/view/wiki.py 2010-06-06 22:32:26 +0000
117@@ -6,6 +6,8 @@
118
119 """View classes to control the rendering of wiki pages."""
120
121+from bzrlib.osutils import format_date
122+
123 from twisted.web.util import redirectTo
124
125 from wikkid.formatter.registry import get_wiki_formatter
126@@ -30,6 +32,14 @@
127 content, formatter = get_wiki_formatter(bytes, 'rest')
128 return formatter.format(self.context.base_name, content)
129
130+ @property
131+ def last_modified_by(self):
132+ return self.context.file_resource.last_modified_by
133+
134+ @property
135+ def last_modified_date(self):
136+ return format_date(self.context.file_resource.last_modified_date)
137+
138 def _render(self, skin):
139 """If the page is not being viewed with the preferred path, redirect.
140

Subscribers

People subscribed via source and target branches