From: richard Date: Thu, 17 Jan 2002 23:04:53 +0000 (+0000) Subject: . much nicer history display (actualy real handling of property types etc) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b5b2580d6a0cf9fa8d4cff774ae57c3b8ccd7921;p=roundup.git . much nicer history display (actualy real handling of property types etc) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@564 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index b43375b..723fe16 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,10 +2,13 @@ This file contains the changes to the Roundup system over time. The entries are given with the most recent entry first. 2002-01-?? - 0.4.0?? - . display superseder as html link in history. - . display links as html link in history (e.g. message history back to issue). +Feature: + . much nicer history display (actualy real handling of property types etc) + +Fixed: . handle attachments with no name (eg tnef) + 2002-01-16 - 0.4.0b2 Fixed: . #495392 ] empty nosy -patch diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 1c449c1..112cb0f 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.60 2002-01-17 08:48:19 grubert Exp $ +# $Id: htmltemplate.py,v 1.61 2002-01-17 23:04:53 richard Exp $ __doc__ = """ Template engine. @@ -184,9 +184,9 @@ class TemplateFunctions: list.sort(sortfunc) l = [] # map the id to the label property - # TODO: allow reversion to the older box style display if not showid: - k = linkcl.labelprop() + k = linkcl.labelprop() value = [linkcl.get(v, k) for v in value] if size is None: size = '10' @@ -439,41 +439,138 @@ class TemplateFunctions: return fp.getvalue() # XXX new function - def do_history(self, **args): + def do_history(self, direction='descending'): ''' list the history of the item + + If "direction" is 'descending' then the most recent event will + be displayed first. If it is 'ascending' then the oldest event + will be displayed first. ''' if self.nodeid is None: return _("[History: node doesn't exist]") l = ['', '', - _(''), - _(''), - _(''), - _('')] - - for id, date, user, action, args in self.cl.history(self.nodeid): - date_s = str(date).replace("."," ") - arg_s = "" - if action=='link' and type(args)==type(()): + _(''), + _(''), + _(''), + _(''), + ''] + + comments = {} + history = self.cl.history(self.nodeid) + if direction == 'descending': + history.reverse() + for id, evt_date, user, action, args in history: + date_s = str(evt_date).replace("."," ") + arg_s = '' + if action == 'link' and type(args) == type(()): if len(args) == 3: - arg_s += '%s%s %s'% (args[0],args[1],args[0],args[1],args[2]) + linkcl, linkid, key = args + arg_s += '%s%s %s'%(linkcl, linkid, + linkcl, linkid, key) else: arg_s = str(arg) - elif type(args)==type({}): + + elif action == 'unlink' and type(args) == type(()): + if len(args) == 3: + linkcl, linkid, key = args + arg_s += '%s%s %s'%(linkcl, linkid, + linkcl, linkid, key) + else: + arg_s = str(arg) + + elif type(args) == type({}): + cell = [] for k in args.keys(): - # special treatment of date, maybe links to files, authors, recipient ? - if k=='superseder' and len(args[k])>0: - arg_s += '
superseder: ' - for ssdr in args[k]: - arg_s += 'issue%s,'%(ssdr,ssdr) + # try to get the relevant property and treat it + # specially + try: + prop = self.properties[k] + except: + prop = None + if prop is not None: + if args[k] and (isinstance(prop, hyperdb.Multilink) or + isinstance(prop, hyperdb.Link)): + # figure what the link class is + classname = prop.classname + try: + linkcl = self.db.classes[classname] + except KeyError, message: + labelprop = None + comments[classname] = _('''The linked class + %(classname)s no longer exists''')%locals() + labelprop = linkcl.labelprop() + + if isinstance(prop, hyperdb.Multilink) and \ + len(args[k]) > 0: + ml = [] + for linkid in args[k]: + label = classname + linkid + # if we have a label property, try to use it + # TODO: test for node existence even when + # there's no labelprop! + try: + if labelprop is not None: + label = linkcl.get(linkid, labelprop) + except IndexError: + comments['no_link'] = _('''The + linked node no longer + exists''') + ml.append('%s'%label) + else: + ml.append('%s'%( + classname, linkid, label)) + cell.append('%s:\n %s'%(k, ',\n '.join(ml))) + elif isinstance(prop, hyperdb.Link) and args[k]: + label = classname + args[k] + # if we have a label property, try to use it + # TODO: test for node existence even when + # there's no labelprop! + if labelprop is not None: + try: + label = linkcl.get(args[k], labelprop) + except IndexError: + comments['no_link'] = _('''The + linked node no longer + exists''') + cell.append(' %s,\n'%label) + else: + cell.append(' %s,\n'%( + classname, linkid, label)) + + elif isinstance(prop, hyperdb.Date) and args[k]: + d = date.Date(args[k]) + cell.append('%s: %s'%(k, str(d))) + + elif isinstance(prop, hyperdb.Interval) and args[k]: + d = date.Interval(args[k]) + cell.append('%s: %s'%(k, str(d))) + + elif not args[k]: + cell.append('%s: (no value)\n'%k) + + else: + cell.append('%s: %s\n'%(k, str(args[k]))) else: - arg_s += '%s: %s,'%(k,str(args[k])) + # property no longer exists + comments['no_exist'] = _('''The indicated property + no longer exists''') + cell.append('%s: %s\n'%(k, str(args[k]))) + arg_s = '
'.join(cell) else: - arg_s = str(args) - # shouldnt _() be used ? - l.append(''%( - date_s, user, action, arg_s)) + # unkown event!! + comments['unknown'] = _('''This event is not + handled by the history display!''') + arg_s = '' + str(args) + '' + date_s = date_s.replace(' ', ' ') + l.append('' + ''%(date_s, + user, action, arg_s)) + if comments: + l.append(_('')) + for entry in comments.values(): + l.append(''%entry) l.append('
DateUserActionArgsDateUserActionArgs
%s%s%s%s
%s%s%s%s
Note:
%s
') return '\n'.join(l) @@ -903,6 +1000,9 @@ class NewItemTemplate(TemplateFunctions): # # $Log: not supported by cvs2svn $ +# Revision 1.60 2002/01/17 08:48:19 grubert +# . display superseder as html link in history. +# # Revision 1.59 2002/01/17 07:58:24 grubert # . display links a html link in history. #