Mercurial > p > roundup > code
changeset 576:f98f37697f4c
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]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 23 Jan 2002 05:10:28 +0000 |
| parents | 2df17627528d |
| children | 334ae707ebfc |
| files | doc/index.html roundup/htmltemplate.py roundup/templates/classic/html/file.index roundup/templates/extended/html/file.index test/test_htmltemplate.py |
| diffstat | 5 files changed, 60 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/index.html Tue Jan 22 22:55:28 2002 +0000 +++ b/doc/index.html Wed Jan 23 05:10:28 2002 +0000 @@ -1009,11 +1009,7 @@ For other properties, link to this node with the property as the text. <p> <em>Options:</em><br> -property (property name) - the property to use in the second case.<br> -is_download (boolean) - to be used for links te <em>file</em> class nodes - -this indicates that the URL should have the specified property (usually -<em>name</em>) 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. </td></tr> <tr><td valign="top"><strong>count</strong></td> @@ -1037,8 +1033,13 @@ </td></tr> <tr><td valign="top"><strong>download</strong></td> -<td>Show a Link("file") or Multilink("file") -property using links that allow you to download files. +<td>For a Link or Multilink property, display the names of the linked +nodes, hyperlinked to the item views on those nodes. +<p> +For other properties, link to this node with the property as the text. +<p> +In all cases, append the name (key property) of the item to the path so it +is the name of the file being downloaded. <p> <em>Arguments:</em><br> property (property name) - the property to use. @@ -1303,7 +1304,7 @@ <p> </p> <hr> -$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 $ <p> </p> </body></html>
--- a/roundup/htmltemplate.py Tue Jan 22 22:55:28 2002 +0000 +++ b/roundup/htmltemplate.py Wed Jan 23 05:10:28 2002 +0000 @@ -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 @@ ''' 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 '<a href="%s%s">%s</a>'%(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('<a href="%s%s">%s</a>'%(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 @@ 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 @@ 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 @@ # # $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 #
--- a/roundup/templates/classic/html/file.index Tue Jan 22 22:55:28 2002 +0000 +++ b/roundup/templates/classic/html/file.index Wed Jan 23 05:10:28 2002 +0000 @@ -1,7 +1,7 @@ -<!-- $Id: file.index,v 1.3 2001-10-21 11:42:15 richard Exp $--> +<!-- $Id: file.index,v 1.4 2002-01-23 05:10:27 richard Exp $--> <tr> <property name="name"> - <td><display call="link('name', is_download=1)"></td> + <td><display call="download('name')"></td> </property> <property name="type"> <td><display call="plain('type')"></td>
--- a/roundup/templates/extended/html/file.index Tue Jan 22 22:55:28 2002 +0000 +++ b/roundup/templates/extended/html/file.index Wed Jan 23 05:10:28 2002 +0000 @@ -1,7 +1,7 @@ -<!-- $Id: file.index,v 1.2 2001-10-21 11:42:15 richard Exp $--> +<!-- $Id: file.index,v 1.3 2002-01-23 05:10:28 richard Exp $--> <tr> <property name="name"> - <td><display call="link('name', is_download=1)"></td> + <td><display call="download('name')"></td> </property> <property name="type"> <td><display call="plain('type')"></td>
--- a/test/test_htmltemplate.py Tue Jan 22 22:55:28 2002 +0000 +++ b/test/test_htmltemplate.py Wed Jan 23 05:10:28 2002 +0000 @@ -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 @@ # 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'), '''<select name="link"> @@ -235,12 +236,46 @@ self.assertEqual(self.tf.do_reldate('date', pretty=1), ' 1 January 2000') +# def do_download(self, property): + def testDownload_novalue(self): + self.assertEqual(self.tf.do_download('novalue'), + _('[no %(propname)s]')%{'propname':'novalue'.capitalize()}) + + def testDownload_string(self): + self.assertEqual(self.tf.do_download('string'), + '<a href="test_class1/Node 1: I am a string">Node 1: ' + 'I am a string</a>') + + def testDownload_file(self): + self.assertEqual(self.tf.do_download('filename', is_download=1), + '<a href="test_class1/file.foo">file.foo</a>') + + def testDownload_date(self): + self.assertEqual(self.tf.do_download('date'), + '<a href="test_class1/2000-01-01.00:00:00">2000-01-01.00:00:00</a>') + + def testDownload_interval(self): + self.assertEqual(self.tf.do_download('interval'), + '<a href="test_class1/- 3d">- 3d</a>') + + def testDownload_link(self): + self.assertEqual(self.tf.do_download('link'), + '<a href="other1/the key">the key</a>') + + def testDownload_multilink(self): + self.assertEqual(self.tf.do_download('multilink'), + '<a href="other1/the key">the key</a>, ' + '<a href="other2/the key">the key</a>') + def suite(): return unittest.makeSuite(NodeCase, 'test') # # $Log: not supported by cvs2svn $ +# Revision 1.4 2002/01/22 22:46:22 richard +# more htmltemplate cleanups and unit tests +# # Revision 1.3 2002/01/22 06:35:40 richard # more htmltemplate tests and cleanup #
