Skip to content

Commit 2ddede0

Browse files
author
Richard Jones
committed
handle Boolean values in history HTML display
1 parent 00adc9c commit 2ddede0

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Fixed:
88
places (thanks Toby Sargeant)
99
- MySQL and Postgresql use BOOL/BOOLEAN for Boolean types
1010
- OTK generation was busted (thanks Stuart D. Gathman)
11+
- handle Boolean values in history HTML display
1112

1213

1314
2004-03-27 0.7.0b2

roundup/cgi/templating.py

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -689,25 +689,27 @@ def history(self, direction='descending', dre=re.compile('\d+')):
689689
timezone = self._db.getUserTimezone()
690690
if direction == 'descending':
691691
history.reverse()
692+
# pre-load the history with the current state
692693
for prop_n in self._props.keys():
693694
prop = self[prop_n]
694-
if isinstance(prop, HTMLProperty):
695-
current[prop_n] = prop.plain()
696-
# make link if hrefable
697-
if (self._props.has_key(prop_n) and
698-
isinstance(self._props[prop_n], hyperdb.Link)):
699-
classname = self._props[prop_n].classname
700-
try:
701-
template = find_template(self._db.config.TEMPLATES,
702-
classname, 'item')
703-
if template[1].startswith('_generic'):
704-
raise NoTemplate, 'not really...'
705-
except NoTemplate:
706-
pass
707-
else:
708-
id = self._klass.get(self._nodeid, prop_n, None)
709-
current[prop_n] = '<a href="%s%s">%s</a>'%(
710-
classname, id, current[prop_n])
695+
if not isinstance(prop, HTMLProperty):
696+
continue
697+
current[prop_n] = prop.plain()
698+
# make link if hrefable
699+
if (self._props.has_key(prop_n) and
700+
isinstance(self._props[prop_n], hyperdb.Link)):
701+
classname = self._props[prop_n].classname
702+
try:
703+
template = find_template(self._db.config.TEMPLATES,
704+
classname, 'item')
705+
if template[1].startswith('_generic'):
706+
raise NoTemplate, 'not really...'
707+
except NoTemplate:
708+
pass
709+
else:
710+
id = self._klass.get(self._nodeid, prop_n, None)
711+
current[prop_n] = '<a href="%s%s">%s</a>'%(
712+
classname, id, current[prop_n])
711713

712714
for id, evt_date, user, action, args in history:
713715
date_s = str(evt_date.local(timezone)).replace("."," ")
@@ -829,17 +831,25 @@ def history(self, direction='descending', dre=re.compile('\d+')):
829831
current[k] = str(d)
830832

831833
elif isinstance(prop, hyperdb.Interval) and args[k]:
832-
d = date.Interval(args[k])
833-
cell.append('%s: %s'%(k, str(d)))
834+
val = str(date.Interval(args[k]))
835+
cell.append('%s: %s'%(k, val))
834836
if current.has_key(k):
835837
cell[-1] += ' -> %s'%current[k]
836-
current[k] = str(d)
838+
current[k] = val
837839

838840
elif isinstance(prop, hyperdb.String) and args[k]:
839-
cell.append('%s: %s'%(k, cgi.escape(args[k])))
841+
val = cgi.escape(args[k])
842+
cell.append('%s: %s'%(k, val))
843+
if current.has_key(k):
844+
cell[-1] += ' -> %s'%current[k]
845+
current[k] = val
846+
847+
elif isinstance(prop, hyperdb.Boolean) and args[k] is not None:
848+
val = args[k] and 'Yes' or 'No'
849+
cell.append('%s: %s'%(k, val))
840850
if current.has_key(k):
841851
cell[-1] += ' -> %s'%current[k]
842-
current[k] = cgi.escape(args[k])
852+
current[k] = val
843853

844854
elif not args[k]:
845855
if current.has_key(k):

0 commit comments

Comments
 (0)