diff roundup/cgi/templating.py @ 2614:c64ea31a569b

merge from HEAD, with some additional code re-arranging
author Richard Jones <richard@users.sourceforge.net>
date Thu, 22 Jul 2004 00:43:55 +0000
parents 5f52d113de0c
children 11811b313459
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Wed Jul 21 04:50:40 2004 +0000
+++ b/roundup/cgi/templating.py	Thu Jul 22 00:43:55 2004 +0000
@@ -762,44 +762,37 @@
     def history(self, direction='descending', dre=re.compile('^\d+$')):
         self.view_check()
 
-        l = ['<table class="history">'
-             '<tr><th colspan="4" class="header">',
-             self._('History'),
-             '</th></tr><tr>',
-             self._('<th>Date</th>'),
-             self._('<th>User</th>'),
-             self._('<th>Action</th>'),
-             self._('<th>Args</th>'),
-            '</tr>']
+        # pre-load the history with the current state
         current = {}
-        comments = {}
+        for prop_n in self._props.keys():
+            prop = self[prop_n]
+            if not isinstance(prop, HTMLProperty):
+                continue
+            current[prop_n] = prop.plain()
+            # make link if hrefable
+            if (self._props.has_key(prop_n) and
+                    isinstance(self._props[prop_n], hyperdb.Link)):
+                classname = self._props[prop_n].classname
+                try:
+                    template = find_template(self._db.config.TEMPLATES,
+                        classname, 'item')
+                    if template[1].startswith('_generic'):
+                        raise NoTemplate, 'not really...'
+                except NoTemplate:
+                    pass
+                else:
+                    id = self._klass.get(self._nodeid, prop_n, None)
+                    current[prop_n] = '<a href="%s%s">%s</a>'%(
+                        classname, id, current[prop_n])
+ 
+        # get the journal, sort and reverse
         history = self._klass.history(self._nodeid)
         history.sort()
+        history.reverse()
+
         timezone = self._db.getUserTimezone()
-        if direction == 'descending':
-            history.reverse()
-            # pre-load the history with the current state
-            for prop_n in self._props.keys():
-                prop = self[prop_n]
-                if not isinstance(prop, HTMLProperty):
-                    continue
-                current[prop_n] = prop.plain()
-                # make link if hrefable
-                if (self._props.has_key(prop_n) and
-                        isinstance(self._props[prop_n], hyperdb.Link)):
-                    classname = self._props[prop_n].classname
-                    try:
-                        template = find_template(self._db.config.TEMPLATES,
-                            classname, 'item')
-                        if template[1].startswith('_generic'):
-                            raise NoTemplate, 'not really...'
-                    except NoTemplate:
-                        pass
-                    else:
-                        id = self._klass.get(self._nodeid, prop_n, None)
-                        current[prop_n] = '<a href="%s%s">%s</a>'%(
-                            classname, id, current[prop_n])
-
+        l = []
+        comments = {}
         for id, evt_date, user, action, args in history:
             date_s = str(evt_date.local(timezone)).replace("."," ")
             arg_s = ''
@@ -976,6 +969,19 @@
                 '<tr><td colspan=4><strong>Note:</strong></td></tr>'))
         for entry in comments.values():
             l.append('<tr><td colspan=4>%s</td></tr>'%entry)
+
+        if direction == 'ascending':
+            l.reverse()
+
+        l[0:0] = ['<table class="history">'
+             '<tr><th colspan="4" class="header">',
+             self._('History'),
+             '</th></tr><tr>',
+             self._('<th>Date</th>'),
+             self._('<th>User</th>'),
+             self._('<th>Action</th>'),
+             self._('<th>Args</th>'),
+            '</tr>']
         l.append('</table>')
         return '\n'.join(l)
 

Roundup Issue Tracker: http://roundup-tracker.org/