|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: htmltemplate.py,v 1.100 2002-07-18 07:01:54 richard Exp $ |
| 18 | +# $Id: htmltemplate.py,v 1.101 2002-07-18 11:17:30 gmcm Exp $ |
19 | 19 |
|
20 | 20 | __doc__ = """ |
21 | 21 | Template engine. |
@@ -107,6 +107,10 @@ def do_plain(self, property, escape=0, lookup=1): |
107 | 107 | value = str(value) |
108 | 108 | elif isinstance(propclass, hyperdb.Interval): |
109 | 109 | value = str(value) |
| 110 | + elif isinstance(propclass, hyperdb.Number): |
| 111 | + value = str(value) |
| 112 | + elif isinstance(propclass, hyperdb.Boolean): |
| 113 | + value = value and "Yes" or "No" |
110 | 114 | elif isinstance(propclass, hyperdb.Link): |
111 | 115 | if value: |
112 | 116 | if lookup: |
@@ -199,6 +203,11 @@ def do_field(self, property, size=None, showid=0): |
199 | 203 | value = cgi.escape(str(value)) |
200 | 204 | value = '"'.join(value.split('"')) |
201 | 205 | s = '<input name="%s" value="%s" size="%s">'%(property, value, size) |
| 206 | + elif isinstance(propclass, hyperdb.Boolean): |
| 207 | + checked = value and "checked" or "" |
| 208 | + s = '<input type="checkbox" name="%s" %s>'%(property, checked) |
| 209 | + elif isinstance(propclass, hyperdb.Number): |
| 210 | + s = '<input name="%s" value="%s" size="%s">'%(property, value, size) |
202 | 211 | elif isinstance(propclass, hyperdb.Password): |
203 | 212 | s = '<input type="password" name="%s" size="%s">'%(property, size) |
204 | 213 | elif isinstance(propclass, hyperdb.Link): |
@@ -268,7 +277,7 @@ def do_multiline(self, property, rows=5, cols=40): |
268 | 277 | property, rows, cols, value) |
269 | 278 |
|
270 | 279 | def do_menu(self, property, size=None, height=None, showid=0, |
271 | | - additional=[]): |
| 280 | + additional=[], **conditions): |
272 | 281 | ''' For a Link/Multilink property, display a menu of the available |
273 | 282 | choices |
274 | 283 |
|
@@ -297,8 +306,8 @@ def do_menu(self, property, size=None, height=None, showid=0, |
297 | 306 | if linkcl.getprops().has_key('order'): |
298 | 307 | sort_on = 'order' |
299 | 308 | else: |
300 | | - sort_on = linkcl.labelprop() |
301 | | - options = linkcl.filter(None, {}, [sort_on], []) |
| 309 | + sort_on = linkcl.labelprop() |
| 310 | + options = linkcl.filter(None, conditions, [sort_on], []) |
302 | 311 | height = height or min(len(options), 7) |
303 | 312 | l = ['<select multiple name="%s" size="%s">'%(property, height)] |
304 | 313 | k = linkcl.labelprop(1) |
@@ -337,8 +346,8 @@ def do_menu(self, property, size=None, height=None, showid=0, |
337 | 346 | if linkcl.getprops().has_key('order'): |
338 | 347 | sort_on = 'order' |
339 | 348 | else: |
340 | | - sort_on = linkcl.labelprop() |
341 | | - options = linkcl.filter(None, {}, [sort_on], []) |
| 349 | + sort_on = linkcl.labelprop() |
| 350 | + options = linkcl.filter(None, conditions, [sort_on], []) |
342 | 351 | for optionid in options: |
343 | 352 | option = linkcl.get(optionid, k) |
344 | 353 | s = '' |
@@ -1135,6 +1144,18 @@ def filter_form(self, search_text, filter, columns, group, all_columns, sort, fi |
1135 | 1144 | op = "equals " |
1136 | 1145 | xtra = "" |
1137 | 1146 | val = filterspec.get(nm, '') |
| 1147 | + elif isinstance(propdescr, hyperdb.Boolean): |
| 1148 | + op = "is " |
| 1149 | + xtra = "" |
| 1150 | + val = filterspec.get(nm, None) |
| 1151 | + if val is not None: |
| 1152 | + val = 'True' and val or 'False' |
| 1153 | + else: |
| 1154 | + val = '' |
| 1155 | + elif isinstance(propdescr, hyperdb.Number): |
| 1156 | + op = "equals " |
| 1157 | + xtra = "" |
| 1158 | + val = str(filterspec.get(nm, '')) |
1138 | 1159 | else: |
1139 | 1160 | w('<td></td><td></td><td></td></tr>') |
1140 | 1161 | continue |
@@ -1341,6 +1362,9 @@ def render(self, form): |
1341 | 1362 |
|
1342 | 1363 | # |
1343 | 1364 | # $Log: not supported by cvs2svn $ |
| 1365 | +# Revision 1.100 2002/07/18 07:01:54 richard |
| 1366 | +# minor bugfix |
| 1367 | +# |
1344 | 1368 | # Revision 1.99 2002/07/17 12:39:10 gmcm |
1345 | 1369 | # Saving, running & editing queries. |
1346 | 1370 | # |
|
0 commit comments