From: richard Date: Wed, 23 Jan 2002 05:10:28 +0000 (+0000) Subject: More HTML template cleanup and unit tests. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=295d74d26099e5316a115d7d1ea9e529e331d4ca;p=roundup.git More HTML template cleanup and unit tests. - download() now implemented correctly, replacing link(is_download=1) [fixed in the templates, but link(is_download=1) will still work for existing templates] git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@588 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/doc/index.html b/doc/index.html index c047a4a..3e05a2f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1009,11 +1009,7 @@ nodes, hyperlinked to the item views on those nodes. For other properties, link to this node with the property as the text.

Options:
-property (property name) - the property to use in the second case.
-is_download (boolean) - to be used for links te file class nodes - -this indicates that the URL should have the specified property (usually -name) appended so that the download has the correct name (instead -of the node designator.) +property (property name) - the property to use in the second case. count @@ -1037,8 +1033,13 @@ pretty (boolean) - display the relative date in an English form. download -Show a Link("file") or Multilink("file") -property using links that allow you to download files. +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 text. +

+In all cases, append the name (key property) of the item to the path so it +is the name of the file being downloaded.

Arguments:
property (property name) - the property to use. @@ -1303,7 +1304,7 @@ system on their time.

 


-$Id: index.html,v 1.26 2002-01-16 04:54:27 richard Exp $ +$Id: index.html,v 1.27 2002-01-23 05:10:27 richard Exp $

 

diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 4157729..1590410 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.68 2002-01-22 22:55:28 richard Exp $ +# $Id: htmltemplate.py,v 1.69 2002-01-23 05:10:27 richard Exp $ __doc__ = """ Template engine. @@ -389,20 +389,7 @@ class TemplateFunctions: ''' if not self.nodeid: return _('[Download: not called from item]') - propclass = self.properties[property] - value = self.cl.get(self.nodeid, property) - if isinstance(propclass, hyperdb.Link): - linkcl = self.db.classes[propclass.classname] - linkvalue = linkcl.get(value, k) - return '%s'%(linkcl, value, linkvalue) - if isinstance(propclass, hyperdb.Multilink): - linkcl = self.db.classes[propclass.classname] - l = [] - for value in value: - linkvalue = linkcl.get(value, k) - l.append('%s'%(linkcl, value, linkvalue)) - return ', '.join(l) - return _('[Download: not a link]') + return self.do_link(property, is_download=1) def do_checklist(self, property, **args): @@ -468,7 +455,7 @@ class TemplateFunctions: if not isinstance(propcl, hyperdb.Multilink): return _('[List: not a Multilink]') value = self.cl.get(self.nodeid, property) - value.sort() + value.sort() if reverse: value.reverse() @@ -505,6 +492,7 @@ class TemplateFunctions: comments = {} history = self.cl.history(self.nodeid) + history.sort() if direction == 'descending': history.reverse() for id, evt_date, user, action, args in history: @@ -1048,6 +1036,9 @@ class NewItemTemplate(TemplateFunctions): # # $Log: not supported by cvs2svn $ +# Revision 1.68 2002/01/22 22:55:28 richard +# . htmltemplate list() wasn't sorting... +# # Revision 1.67 2002/01/22 22:46:22 richard # more htmltemplate cleanups and unit tests # diff --git a/roundup/templates/classic/html/file.index b/roundup/templates/classic/html/file.index index d8d7209..ab57d44 100644 --- a/roundup/templates/classic/html/file.index +++ b/roundup/templates/classic/html/file.index @@ -1,7 +1,7 @@ - + - + diff --git a/roundup/templates/extended/html/file.index b/roundup/templates/extended/html/file.index index 50c1697..ab69ce6 100644 --- a/roundup/templates/extended/html/file.index +++ b/roundup/templates/extended/html/file.index @@ -1,7 +1,7 @@ - + - + diff --git a/test/test_htmltemplate.py b/test/test_htmltemplate.py index 3757239..d7b15f0 100644 --- a/test/test_htmltemplate.py +++ b/test/test_htmltemplate.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_htmltemplate.py,v 1.4 2002-01-22 22:46:22 richard Exp $ +# $Id: test_htmltemplate.py,v 1.5 2002-01-23 05:10:28 richard Exp $ import unittest, cgi @@ -139,10 +139,11 @@ class NodeCase(unittest.TestCase): # def do_menu(self, property, size=None, height=None, showid=0): def testMenu_nonlinks(self): - self.assertEqual(self.tf.do_menu('string'), _('[Menu: not a link]')) - self.assertEqual(self.tf.do_menu('date'), _('[Menu: not a link]')) - self.assertEqual(self.tf.do_menu('interval'), _('[Menu: not a link]')) - self.assertEqual(self.tf.do_menu('password'), _('[Menu: not a link]')) + s = _('[Menu: not a link]') + self.assertEqual(self.tf.do_menu('string'), s) + self.assertEqual(self.tf.do_menu('date'), s) + self.assertEqual(self.tf.do_menu('interval'), s) + self.assertEqual(self.tf.do_menu('password'), s) def testMenu_link(self): self.assertEqual(self.tf.do_menu('link'), '''