From 4dcc983fbe0cb8200829603c29fe72256de6deb6 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 31 Mar 2004 23:45:28 +0000 Subject: [PATCH] handle Boolean values in history HTML display git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2240 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + roundup/cgi/templating.py | 54 +++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b48d2d2..7ed151b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,7 @@ Fixed: places (thanks Toby Sargeant) - MySQL and Postgresql use BOOL/BOOLEAN for Boolean types - OTK generation was busted (thanks Stuart D. Gathman) +- handle Boolean values in history HTML display 2004-03-27 0.7.0b2 diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 372b8fe..50f612a 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -689,25 +689,27 @@ class HTMLItem(HTMLInputMixin, HTMLPermissions): 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 isinstance(prop, HTMLProperty): - 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] = '%s'%( - classname, id, current[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] = '%s'%( + classname, id, current[prop_n]) for id, evt_date, user, action, args in history: date_s = str(evt_date.local(timezone)).replace("."," ") @@ -829,17 +831,25 @@ class HTMLItem(HTMLInputMixin, HTMLPermissions): current[k] = str(d) elif isinstance(prop, hyperdb.Interval) and args[k]: - d = date.Interval(args[k]) - cell.append('%s: %s'%(k, str(d))) + val = str(date.Interval(args[k])) + cell.append('%s: %s'%(k, val)) if current.has_key(k): cell[-1] += ' -> %s'%current[k] - current[k] = str(d) + current[k] = val elif isinstance(prop, hyperdb.String) and args[k]: - cell.append('%s: %s'%(k, cgi.escape(args[k]))) + val = cgi.escape(args[k]) + cell.append('%s: %s'%(k, val)) + if current.has_key(k): + cell[-1] += ' -> %s'%current[k] + current[k] = val + + elif isinstance(prop, hyperdb.Boolean) and args[k] is not None: + val = args[k] and 'Yes' or 'No' + cell.append('%s: %s'%(k, val)) if current.has_key(k): cell[-1] += ' -> %s'%current[k] - current[k] = cgi.escape(args[k]) + current[k] = val elif not args[k]: if current.has_key(k): -- 2.30.2