summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f611fd1)
raw | patch | inline | side by side (parent: f611fd1)
author | gmcm <gmcm@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 27 Jun 2002 12:05:25 +0000 (12:05 +0000) | ||
committer | gmcm <gmcm@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 27 Jun 2002 12:05:25 +0000 (12:05 +0000) |
In history, make sure there's a .item before making a link / multilink into an href.
Also in history, cgi.escape String properties.
Clean up some of the reference cycles.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@820 57a73879-2fb5-44c3-a270-3262357dd7e2
Also in history, cgi.escape String properties.
Clean up some of the reference cycles.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@820 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/htmltemplate.py | patch | blob | history |
index 6a2ece45eec27e1af49bd9a2fc01c2a26be560e6..ecdfc074d7a911d98245aed15a36c641c5eea295 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.92 2002-06-11 04:57:04 richard Exp $
+# $Id: htmltemplate.py,v 1.93 2002-06-27 12:05:25 gmcm Exp $
__doc__ = """
Template engine.
if value:
if lookup:
linkcl = self.db.classes[propclass.classname]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
value = linkcl.get(value, k)
else:
value = _('[unselected]')
elif isinstance(propclass, hyperdb.Multilink):
if lookup:
linkcl = self.db.classes[propclass.classname]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
labels = []
for v in value:
labels.append(linkcl.get(v, k))
options.sort(sortfunc)
# TODO: make this a field display, not a menu one!
l = ['<select name="%s">'%property]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
if value is None:
s = 'selected '
else:
value.sort(sortfunc)
# map the id to the label property
if not showid:
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
value = [linkcl.get(v, k) for v in value]
value = cgi.escape(','.join(value))
s = '<input name="%s" size="%s" value="%s">'%(property, size, value)
options.sort(sortfunc)
height = height or min(len(options), 7)
l = ['<select multiple name="%s" size="%s">'%(property, height)]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
for optionid in options:
option = linkcl.get(optionid, k)
s = ''
value = value[0]
linkcl = self.db.classes[propclass.classname]
l = ['<select name="%s">'%property]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
s = ''
if value is None:
s = 'selected '
if isinstance(propclass, hyperdb.Link):
linkname = propclass.classname
linkcl = self.db.classes[linkname]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
linkvalue = cgi.escape(str(linkcl.get(value, k)))
if showid:
label = value
if isinstance(propclass, hyperdb.Multilink):
linkname = propclass.classname
linkcl = self.db.classes[linkname]
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
l = []
for value in value:
linkvalue = cgi.escape(str(linkcl.get(value, k)))
# so we can map to the linked node's "lable" property
linkcl = self.db.classes[propclass.classname]
l = []
- k = linkcl.labelprop()
+ k = linkcl.labelprop(1)
for optionid in linkcl.list():
option = cgi.escape(str(linkcl.get(optionid, k)))
if optionid in value or option in value:
labelprop = None
comments[classname] = _('''The linked class
%(classname)s no longer exists''')%locals()
- labelprop = linkcl.labelprop()
+ labelprop = linkcl.labelprop(1)
+ hrefable = os.path.exists(
+ os.path.join(self.templates, classname+'.item'))
if isinstance(prop, hyperdb.Multilink) and \
len(args[k]) > 0:
exists</strike>''')
ml.append('<strike>%s</strike>'%label)
else:
- ml.append('<a href="%s%s">%s</a>'%(
- classname, linkid, label))
+ if hrefable:
+ ml.append('<a href="%s%s">%s</a>'%(
+ classname, linkid, label))
+ else:
+ ml.append(label)
cell.append('%s:\n %s'%(k, ',\n '.join(ml)))
elif isinstance(prop, hyperdb.Link) and args[k]:
label = classname + args[k]
# "flag" this is done .... euwww
label = None
if label is not None:
- cell.append('%s: <a href="%s%s">%s</a>\n'%(k,
- classname, args[k], label))
+ if hrefable:
+ cell.append('%s: <a href="%s%s">%s</a>\n'%(k,
+ classname, args[k], label))
+ else:
+ cell.append('%s: %s' % (k,label))
elif isinstance(prop, hyperdb.Date) and args[k]:
d = date.Date(args[k])
d = date.Interval(args[k])
cell.append('%s: %s'%(k, str(d)))
+ elif isinstance(prop, hyperdb.String) and args[k]:
+ cell.append('%s: %s'%(k, cgi.escape(args[k])))
+
elif not args[k]:
cell.append('%s: (no value)\n'%k)
r'((<property\s+name="(?P<name>[^>]+)">(?P<text>.+?)</property>)|'
r'(?P<display><display\s+call="(?P<command>[^"]+)">))', re.I|re.S)
def go(self, text):
- return self.replace.sub(self, text)
+ newtext = self.replace.sub(self, text)
+ self.locals = self.globals = None
+ return newtext
def __call__(self, m, search_text=None, filter=None, columns=None,
sort=None, group=None):
if m.group('name'):
if m.group('name') in self.props:
text = m.group('text')
- replace = IndexTemplateReplace(self.globals, {}, self.props)
+ replace = self.__class__(self.globals, {}, self.props)
return replace.go(text)
else:
return ''
def render(self, filterspec={}, search_text='', filter=[], columns=[],
sort=[], group=[], show_display_form=1, nodeids=None,
show_customization=1, show_nodes=1):
+
self.filterspec = filterspec
w = self.client.write
','.join(sort))
w('</form>\n')
+ self.db = self.cl = self.properties = None
+
def node_matches(self, match, colspan):
''' display the files and messages for a node that matched a
full text search
file_links = []
if match.has_key('messages'):
for msgid in match['messages']:
- k = self.db.msg.labelprop()
+ k = self.db.msg.labelprop(1)
lab = self.db.msg.get(msgid, k)
msgpath = 'msg%s'%msgid
message_links.append('<a href="%(msgpath)s">%(lab)s</a>'
r'((<property\s+name="(?P<name>[^>]+)">(?P<text>.+?)</property>)|'
r'(?P<display><display\s+call="(?P<command>[^"]+)">))', re.I|re.S)
def go(self, text):
- return self.replace.sub(self, text)
+ newtext = self.replace.sub(self, text)
+ self.globals = self.locals = self.cl = None
+ return newtext
def __call__(self, m, filter=None, columns=None, sort=None, group=None):
if m.group('name'):
replace = ItemTemplateReplace(self.globals, locals(), self.cl, nodeid)
w(replace.go(s))
w('</form>')
+ self.cl = self.db = self.properties = None
class NewItemTemplate(TemplateFunctions):
replace = ItemTemplateReplace(self.globals, locals(), None, None)
w(replace.go(s))
w('</form>')
+ self.cl = self.db = None
#
# $Log: not supported by cvs2svn $
+# Revision 1.92 2002/06/11 04:57:04 richard
+# Added optional additional property to display in a Multilink form menu.
+#
# Revision 1.91 2002/05/31 00:08:02 richard
# can now just display a link/multilink id - useful for stylesheet stuff
#