Code

don't show entire history by default (fixes http://bugs.debian.org/cgi-bin/bugreport...
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 10 Aug 2009 02:02:00 +0000 (02:02 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 10 Aug 2009 02:02:00 +0000 (02:02 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4338 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi/templating.py
share/roundup/templates/classic/html/_generic.item.html
share/roundup/templates/minimal/html/_generic.item.html

index 1cae36afca92049fdf2b29cbb79f87df2acb1e4d..2087508e53e49aa5e47c388bf1463584faa3fad7 100644 (file)
@@ -880,7 +880,8 @@ class _HTMLItem(HTMLInputMixin, HTMLPermissions):
         # XXX do this
         return []
 
-    def history(self, direction='descending', dre=re.compile('^\d+$')):
+    def history(self, direction='descending', dre=re.compile('^\d+$'),
+            limit=None):
         if not self.is_view_ok():
             return self._('[hidden]')
 
@@ -912,6 +913,10 @@ class _HTMLItem(HTMLInputMixin, HTMLPermissions):
         history.sort()
         history.reverse()
 
+        # restrict the volume
+        if limit:
+            history = history[:limit]
+
         timezone = self._db.getUserTimezone()
         l = []
         comments = {}
index d9b98aefc0a8418f4d695dba36ad989c37286f0b..9ce1f1a1e313dda004f736e976a7d4bee80e2f5d 100644 (file)
 
 </form>
 
-<tal:block tal:condition="context/id" tal:replace="structure context/history" />
+<tal:block tal:condition="context/id"
+    tal:define="limit python:[10, None][request.form.has_key('show_all_history')]"
+    tal:replace="structure python:context.history(limit=limit)" />
+<p tal:condition="not:exists:request/form/show_all_history" i18n:translate="">Showing 10 items.
+<a tal:attributes="href string:${context/_classname}${context/id}?show_all_history=yes">Show all history</a>
+(warning: this could be VERY long)</p>
 
 </div>
 
index ac60acb2b3d9c415ed6ca607fcf3e96ac79cc7a7..9ce1f1a1e313dda004f736e976a7d4bee80e2f5d 100644 (file)
@@ -9,18 +9,18 @@
 
 <td class="content" metal:fill-slot="content">
 
-<span tal:condition="python:not (context.is_view_ok() or context.is_edit_ok()
- or request.user.hasRole('Anonymous'))"
- tal:omit-tag="python:1" i18n:translate=""
->You are not allowed to view this page.</span>
+<p tal:condition="python:not (context.is_view_ok()
+ or request.user.hasRole('Anonymous'))" i18n:translate="">
+ You are not allowed to view this page.</p>
 
-<span tal:condition="python:not (context.is_view_ok() or context.is_edit_ok())
- and request.user.hasRole('Anonymous')"
- tal:omit-tag="python:1" i18n:translate=""
->Please login with your username and password.</span>
+<p tal:condition="python:not context.is_view_ok()
+ and request.user.hasRole('Anonymous')" i18n:translate="">
+ Please login with your username and password.</p>
+
+<div tal:condition="context/is_view_ok">
 
 <form method="POST" onSubmit="return submit_once()"
-      enctype="multipart/form-data" tal:condition="context/is_edit_ok"
+      enctype="multipart/form-data" tal:condition="context/is_view_ok"
       tal:attributes="action context/designator">
 
 <input type="hidden" name="@template" value="item">
 
 </form>
 
-<table class="form" tal:condition="context/is_only_view_ok">
-
-<tr tal:repeat="prop python:db[context._classname].properties()">
- <tal:block tal:condition="python:prop._name not in ('id', 'creator',
-                                  'creation', 'activity')">
-  <th tal:content="prop/_name"></th>
-  <td tal:content="structure python:context[prop._name].field()"></td>
- </tal:block>
-</tr>
-</table>
-
+<tal:block tal:condition="context/id"
+    tal:define="limit python:[10, None][request.form.has_key('show_all_history')]"
+    tal:replace="structure python:context.history(limit=limit)" />
+<p tal:condition="not:exists:request/form/show_all_history" i18n:translate="">Showing 10 items.
+<a tal:attributes="href string:${context/_classname}${context/id}?show_all_history=yes">Show all history</a>
+(warning: this could be VERY long)</p>
 
-<tal:block tal:condition="python:context.id and context.is_view_ok()">
- <tal:block tal:replace="structure context/history" />
-</tal:block>
+</div>
 
 </td>