source: trunk/packages/sipb-xen-www/code/templates/functions.tmpl @ 451

Last change on this file since 451 was 447, checked in by ecprice, 17 years ago

Avoid html injection.

Cheetah is painful.

File size: 1.6 KB
RevLine 
[447]1#filter WebSafe
[443]2#def databaseList($lst, $default, $onchange, $name, $id, $valueattr, $descattr)
3<select name="$name" id="$id"#slurp
4#if $onchange is not None
5onchange="$onchange"#slurp
6#end if
7>
[205]8  <option #slurp
9#if $default then '' else 'selected'
10 value="">None</option>
[443]11  #for $item in $lst
[205]12  <option #slurp
[443]13#if $default == getattr(item, valueattr) then 'selected' else ''
14 value="${getattr(item, valueattr)}">
15    ${getattr(item, descattr)}
[205]16  </option>
17  #end for
18</select>
19#end def
20
[443]21#def cdromList($default="", $onchange=None)
[447]22#filter None
[443]23$databaseList(sorted($sipb_xen_database.CDROM.select(), key=lambda x: x.description),
24              default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description')
[447]25#end filter
[443]26#end def
27
28#def autoList($default="", $onchange=None)
[447]29#filter None
[443]30$databaseList(sorted($sipb_xen_database.Autoinstall.select(), key=lambda x: x.description),
31              default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')
[447]32#end filter
[443]33#end def
34
[440]35#def vmTypeList($default=None)
[441]36#for $vmtype in sorted($sipb_xen_database.Type.select(), key=lambda x: x.description)
[440]37<label>
38   <input #slurp
39#if $default == $vmtype then 'checked' else ''
40 type="radio" name="vmtype" value="${vmtype.type_id}">${vmtype.description}</input>
41</label>
42#end for
43#end def
44
[205]45#def addError(txt)
46#if $varExists('txt')
47#set global $error_text = $error_text + '----\n' + $txt
48#else
49#set global $error_text = $txt
50#end if
51#end def
52
53#def errorRow($value, $err)
54#if $err and $err.err_field == $value
55<tr>
56<td class="error" colspan="2">${str($err)}</td>
57</tr>
58#end if
59#end def
[447]60#filter None
61$full_body
62#end filter
63#end filter
Note: See TracBrowser for help on using the repository browser.