index 55f7fee2e68f43a4ca06270a389e7eee86b2ded6..2f6557a1fdb0abba2b3e4d660048c9cfdc2e923b 100644 (file)
--- a/roundup/htmltemplate.py
+++ b/roundup/htmltemplate.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: htmltemplate.py,v 1.83 2002-02-27 04:14:31 richard Exp $
+# $Id: htmltemplate.py,v 1.89 2002-05-15 06:34:47 richard Exp $
__doc__ = """
Template engine.
"""
-import os, re, StringIO, urllib, cgi, errno, types
+import os, re, StringIO, urllib, cgi, errno, types, urllib
import hyperdb, date
from i18n import _
elif isinstance(propclass, hyperdb.Multilink):
linkcl = self.db.classes[propclass.classname]
k = linkcl.labelprop()
- value = ', '.join(value)
+ labels = []
+ for v in value:
+ labels.append(linkcl.get(v, k))
+ value = ', '.join(labels)
else:
value = _('Plain: bad propclass "%(propclass)s"')%locals()
if escape:
elif isinstance(propclass, hyperdb.Multilink):
sortfunc = self.make_sort_function(propclass.classname)
linkcl = self.db.classes[propclass.classname]
- list = linkcl.list()
- list.sort(sortfunc)
- l = []
+ if value:
+ value.sort(sortfunc)
# map the id to the label property
if not showid:
k = linkcl.labelprop()
for optionid in options:
option = linkcl.get(optionid, k)
s = ''
- if optionid in value:
+ if optionid in value or option in value:
s = 'selected '
if showid:
lab = '%s%s: %s'%(propclass.classname, optionid, option)
for optionid in options:
option = linkcl.get(optionid, k)
s = ''
- if optionid == value:
+ if value in [optionid, option]:
s = 'selected '
if showid:
lab = '%s%s: %s'%(propclass.classname, optionid, option)
return _('[Menu: not a link]')
#XXX deviates from spec
- def do_link(self, property=None, is_download=0):
+ def do_link(self, property=None, is_download=0, showid=0):
'''For a Link or Multilink property, display the names of the linked
nodes, hyperlinked to the item views on those nodes.
For other properties, link to this node with the property as the
linkname = propclass.classname
linkcl = self.db.classes[linkname]
k = linkcl.labelprop()
- linkvalue = cgi.escape(linkcl.get(value, k))
+ linkvalue = cgi.escape(str(linkcl.get(value, k)))
+ if showid:
+ label = value
+ title = ' title="%s"'%linkvalue
+ # note ... this should be urllib.quote(linkcl.get(value, k))
+ else:
+ label = linkvalue
+ title = ''
if is_download:
- return '<a href="%s%s/%s">%s</a>'%(linkname, value,
- linkvalue, linkvalue)
+ return '<a href="%s%s/%s"%s>%s</a>'%(linkname, value,
+ linkvalue, title, label)
else:
- return '<a href="%s%s">%s</a>'%(linkname, value, linkvalue)
+ return '<a href="%s%s"%s>%s</a>'%(linkname, value, title, label)
if isinstance(propclass, hyperdb.Multilink):
linkname = propclass.classname
linkcl = self.db.classes[linkname]
k = linkcl.labelprop()
l = []
for value in value:
- linkvalue = cgi.escape(linkcl.get(value, k))
+ linkvalue = cgi.escape(str(linkcl.get(value, k)))
+ if showid:
+ label = value
+ title = ' title="%s"'%linkvalue
+ # note ... this should be urllib.quote(linkcl.get(value, k))
+ else:
+ label = linkvalue
+ title = ''
if is_download:
- l.append('<a href="%s%s/%s">%s</a>'%(linkname, value,
- linkvalue, linkvalue))
+ l.append('<a href="%s%s/%s"%s>%s</a>'%(linkname, value,
+ linkvalue, title, label))
else:
- l.append('<a href="%s%s">%s</a>'%(linkname, value,
- linkvalue))
+ l.append('<a href="%s%s"%s>%s</a>'%(linkname, value,
+ title, label))
return ', '.join(l)
if is_download:
return '<a href="%s%s/%s">%s</a>'%(self.classname, self.nodeid,
if pretty:
if not self.nodeid:
return _('now')
- pretty = interval.pretty()
- if pretty is None:
- pretty = value.pretty()
- return pretty
+ return interval.pretty()
return str(interval)
def do_download(self, property, **args):
l = []
k = linkcl.labelprop()
for optionid in linkcl.list():
- option = cgi.escape(linkcl.get(optionid, k))
+ option = cgi.escape(str(linkcl.get(optionid, k)))
if optionid in value or option in value:
checked = 'checked'
else:
#
# $Log: not supported by cvs2svn $
+# Revision 1.88 2002/04/24 08:34:35 rochecompaan
+# Sorting was applied to all nodes of the MultiLink class instead of
+# the nodes that are actually linked to in the "field" template
+# function. This adds about 20+ seconds in the display of an issue if
+# your database has a 1000 or more issue in it.
+#
+# Revision 1.87 2002/04/03 06:12:46 richard
+# Fix for date properties as labels.
+#
+# Revision 1.86 2002/04/03 05:54:31 richard
+# Fixed serialisation problem by moving the serialisation step out of the
+# hyperdb.Class (get, set) into the hyperdb.Database.
+#
+# Also fixed htmltemplate after the showid changes I made yesterday.
+#
+# Unit tests for all of the above written.
+#
+# Revision 1.85 2002/04/02 01:40:58 richard
+# . link() htmltemplate function now has a "showid" option for links and
+# multilinks. When true, it only displays the linked node id as the anchor
+# text. The link value is displayed as a tooltip using the title anchor
+# attribute.
+#
+# Revision 1.84 2002/03/29 19:41:48 rochecompaan
+# . Fixed display of mutlilink properties when using the template
+# functions, menu and plain.
+#
+# Revision 1.83 2002/02/27 04:14:31 richard
+# Ran it through pychecker, made fixes
+#
# Revision 1.82 2002/02/21 23:11:45 richard
# . fixed some problems in date calculations (calendar.py doesn't handle over-
# and under-flow). Also, hour/minute/second intervals may now be more than