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

Last change on this file since 1314 was 1001, checked in by broder, 16 years ago

Update (at least some of) the web code to work with newer a SQLAlchemy

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
[1001]23$databaseList(sorted($database.CDROM.query(), key=lambda x: x.description),
[443]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
[1001]30$databaseList(sorted($database.Autoinstall.query(), key=lambda x: x.description),
[443]31              default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')
[447]32#end filter
[443]33#end def
34
[440]35#def vmTypeList($default=None)
[512]36#for $vmtype in (('linux-hvm', 'HVM'), ('linux', 'ParaVM'), )
[440]37<label>
38   <input #slurp
[515]39#if $default == $vmtype[0] then 'checked' else ''
[512]40 type="radio" name="vmtype" value="${vmtype[0]}">${vmtype[1]}</input>
[440]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
[864]63#end filter
Note: See TracBrowser for help on using the repository browser.