@@ -685,43 +685,36 @@ def journal(self, direction='descending'):
685685 def history (self , direction = 'descending' , dre = re .compile ('^\d+$' )):
686686 self .view_check ()
687687
688- l = ['<table class="history">'
689- '<tr><th colspan="4" class="header">' ,
690- _ ('History' ),
691- '</th></tr><tr>' ,
692- _ ('<th>Date</th>' ),
693- _ ('<th>User</th>' ),
694- _ ('<th>Action</th>' ),
695- _ ('<th>Args</th>' ),
696- '</tr>' ]
688+ l = []
697689 current = {}
698690 comments = {}
699691 history = self ._klass .history (self ._nodeid )
700692 history .sort ()
701693 timezone = self ._db .getUserTimezone ()
702- if direction == 'descending' :
703- history .reverse ()
704- # pre-load the history with the current state
705- for prop_n in self ._props .keys ():
706- prop = self [prop_n ]
707- if not isinstance (prop , HTMLProperty ):
708- continue
709- current [prop_n ] = prop .plain ()
710- # make link if hrefable
711- if (self ._props .has_key (prop_n ) and
712- isinstance (self ._props [prop_n ], hyperdb .Link )):
713- classname = self ._props [prop_n ].classname
714- try :
715- template = find_template (self ._db .config .TEMPLATES ,
716- classname , 'item' )
717- if template [1 ].startswith ('_generic' ):
718- raise NoTemplate , 'not really...'
719- except NoTemplate :
720- pass
721- else :
722- id = self ._klass .get (self ._nodeid , prop_n , None )
723- current [prop_n ] = '<a href="%s%s">%s</a>' % (
724- classname , id , current [prop_n ])
694+
695+ history .reverse ()
696+
697+ # pre-load the history with the current state
698+ for prop_n in self ._props .keys ():
699+ prop = self [prop_n ]
700+ if not isinstance (prop , HTMLProperty ):
701+ continue
702+ current [prop_n ] = prop .plain ()
703+ # make link if hrefable
704+ if (self ._props .has_key (prop_n ) and
705+ isinstance (self ._props [prop_n ], hyperdb .Link )):
706+ classname = self ._props [prop_n ].classname
707+ try :
708+ template = find_template (self ._db .config .TEMPLATES ,
709+ classname , 'item' )
710+ if template [1 ].startswith ('_generic' ):
711+ raise NoTemplate , 'not really...'
712+ except NoTemplate :
713+ pass
714+ else :
715+ id = self ._klass .get (self ._nodeid , prop_n , None )
716+ current [prop_n ] = '<a href="%s%s">%s</a>' % (
717+ classname , id , current [prop_n ])
725718
726719 for id , evt_date , user , action , args in history :
727720 date_s = str (evt_date .local (timezone )).replace ("." ," " )
@@ -893,6 +886,19 @@ def history(self, direction='descending', dre=re.compile('^\d+$')):
893886 l .append (_ ('<tr><td colspan=4><strong>Note:</strong></td></tr>' ))
894887 for entry in comments .values ():
895888 l .append ('<tr><td colspan=4>%s</td></tr>' % entry )
889+
890+ if direction == 'ascending' :
891+ l .reverse ()
892+
893+ l [0 :0 ] = ['<table class="history">'
894+ '<tr><th colspan="4" class="header">' ,
895+ _ ('History' ),
896+ '</th></tr><tr>' ,
897+ _ ('<th>Date</th>' ),
898+ _ ('<th>User</th>' ),
899+ _ ('<th>Action</th>' ),
900+ _ ('<th>Args</th>' ),
901+ '</tr>' ]
896902 l .append ('</table>' )
897903 return '\n ' .join (l )
898904
0 commit comments