[Zope3-checkins] CVS: Zope3/src/zope/app/browser - undo.py:1.6 undo_log.pt:1.5

Anthony Baxter anthony@interlink.com.au
Wed, 9 Jul 2003 21:32:19 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser
In directory cvs.zope.org:/tmp/cvs-serv2140

Modified Files:
	undo.py undo_log.pt 
Log Message:
Cleanups for the Undo tab. Show the time of the initial transaction,
and handle the cases where we have no username or no description for
the transaction.


=== Zope3/src/zope/app/browser/undo.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/undo.py:1.5	Wed Jun 25 11:24:20 2003
+++ Zope3/src/zope/app/browser/undo.py	Wed Jul  9 21:32:13 2003
@@ -23,6 +23,7 @@
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.app.interfaces.undo import IUndoManager
 from zope.app.services.servicenames import Utilities
+from datetime import datetime
 
 
 def undoSetup(event):
@@ -49,7 +50,28 @@
     def getUndoInfo(self):
         '''See interface IUndoManager'''
 
-        return self.__db.undoInfo()
+        # Entries are a list of dictionaries, containing
+        # id          -> internal id for zodb
+        # user_name   -> name of user that last accessed the file
+        # time        -> unix timestamp of last access
+        # description -> transaction description
+
+        entries = self.__db.undoInfo()
+
+        # We walk through the entries, (possibly removing some)
+        # and augmenting the dictionaries with some additional
+        # items (such as datetime, a useful form of the unix timestamp).
+        # If there is no description provided, we provide one.
+
+        for e in entries:
+            e['datetime'] = datetime.fromtimestamp(e['time'])
+
+        # Here we'd filter out ones we don't care about (for instance,
+        # to show only entries from the current user).
+
+        return entries
+
+
 
     def undoTransaction(self, id_list):
         '''See interface IUndoManager'''


=== Zope3/src/zope/app/browser/undo_log.pt 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/undo_log.pt:1.4	Wed Jun 25 14:43:02 2003
+++ Zope3/src/zope/app/browser/undo_log.pt	Wed Jul  9 21:32:13 2003
@@ -42,19 +42,22 @@
     <td align="left" valign="top">
     <div class="list-item">
      
-     <span tal:content="undoitem/description"> description </span>
-     by
-     <strong><span tal:content="undoitem/user_name"> user_name </span></strong>
- 
+     <i tal:condition="not:undoitem/description">
+           no description available</i>
+     <span tal:condition="undoitem/description" tal:omit-tag=""
+           tal:content="undoitem/description">description goes here</span>
+     <span tal:condition="undoitem/user_name" tal:omit-tag=""> by 
+         <strong tal:content="undoitem/user_name">user_name</strong>
+     </span>
     </div>
     </td>
-<!--
+
     <td align="right" valign="top" colspan="2" nowrap>
-    <div class="list-item" tal:content="undoitem/time">
+    <div class="list-item" tal:content="python:undoitem['datetime'].strftime('%Y/%m/%d %H:%M:%S')">
       blah date
     </div>
     </td>
--->
+
   </tr>