Skip to content

Commit e6efd94

Browse files
author
Richard Jones
committed
don't show entire history by default
(fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=540629)
1 parent 67a57b3 commit e6efd94

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

roundup/cgi/templating.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ def journal(self, direction='descending'):
880880
# XXX do this
881881
return []
882882

883-
def history(self, direction='descending', dre=re.compile('^\d+$')):
883+
def history(self, direction='descending', dre=re.compile('^\d+$'),
884+
limit=None):
884885
if not self.is_view_ok():
885886
return self._('[hidden]')
886887

@@ -912,6 +913,10 @@ def history(self, direction='descending', dre=re.compile('^\d+$')):
912913
history.sort()
913914
history.reverse()
914915

916+
# restrict the volume
917+
if limit:
918+
history = history[:limit]
919+
915920
timezone = self._db.getUserTimezone()
916921
l = []
917922
comments = {}

share/roundup/templates/classic/html/_generic.item.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444

4545
</form>
4646

47-
<tal:block tal:condition="context/id" tal:replace="structure context/history" />
47+
<tal:block tal:condition="context/id"
48+
tal:define="limit python:[10, None][request.form.has_key('show_all_history')]"
49+
tal:replace="structure python:context.history(limit=limit)" />
50+
<p tal:condition="not:exists:request/form/show_all_history" i18n:translate="">Showing 10 items.
51+
<a tal:attributes="href string:${context/_classname}${context/id}?show_all_history=yes">Show all history</a>
52+
(warning: this could be VERY long)</p>
4853

4954
</div>
5055

share/roundup/templates/minimal/html/_generic.item.html

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99

1010
<td class="content" metal:fill-slot="content">
1111

12-
<span tal:condition="python:not (context.is_view_ok() or context.is_edit_ok()
13-
or request.user.hasRole('Anonymous'))"
14-
tal:omit-tag="python:1" i18n:translate=""
15-
>You are not allowed to view this page.</span>
12+
<p tal:condition="python:not (context.is_view_ok()
13+
or request.user.hasRole('Anonymous'))" i18n:translate="">
14+
You are not allowed to view this page.</p>
1615

17-
<span tal:condition="python:not (context.is_view_ok() or context.is_edit_ok())
18-
and request.user.hasRole('Anonymous')"
19-
tal:omit-tag="python:1" i18n:translate=""
20-
>Please login with your username and password.</span>
16+
<p tal:condition="python:not context.is_view_ok()
17+
and request.user.hasRole('Anonymous')" i18n:translate="">
18+
Please login with your username and password.</p>
19+
20+
<div tal:condition="context/is_view_ok">
2121

2222
<form method="POST" onSubmit="return submit_once()"
23-
enctype="multipart/form-data" tal:condition="context/is_edit_ok"
23+
enctype="multipart/form-data" tal:condition="context/is_view_ok"
2424
tal:attributes="action context/designator">
2525

2626
<input type="hidden" name="@template" value="item">
@@ -44,21 +44,14 @@
4444

4545
</form>
4646

47-
<table class="form" tal:condition="context/is_only_view_ok">
48-
49-
<tr tal:repeat="prop python:db[context._classname].properties()">
50-
<tal:block tal:condition="python:prop._name not in ('id', 'creator',
51-
'creation', 'activity')">
52-
<th tal:content="prop/_name"></th>
53-
<td tal:content="structure python:context[prop._name].field()"></td>
54-
</tal:block>
55-
</tr>
56-
</table>
57-
47+
<tal:block tal:condition="context/id"
48+
tal:define="limit python:[10, None][request.form.has_key('show_all_history')]"
49+
tal:replace="structure python:context.history(limit=limit)" />
50+
<p tal:condition="not:exists:request/form/show_all_history" i18n:translate="">Showing 10 items.
51+
<a tal:attributes="href string:${context/_classname}${context/id}?show_all_history=yes">Show all history</a>
52+
(warning: this could be VERY long)</p>
5853

59-
<tal:block tal:condition="python:context.id and context.is_view_ok()">
60-
<tal:block tal:replace="structure context/history" />
61-
</tal:block>
54+
</div>
6255

6356
</td>
6457

0 commit comments

Comments
 (0)