source: branches/wsgi/packages/sipb-xen-www/code/templates/functions.tmpl @ 1518

Last change on this file since 1518 was 515, checked in by ecprice, 17 years ago

Set the default vm type

File size: 1.6 KB
Line 
1#filter WebSafe
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>
8  <option #slurp
9#if $default then '' else 'selected'
10 value="">None</option>
11  #for $item in $lst
12  <option #slurp
13#if $default == getattr(item, valueattr) then 'selected' else ''
14 value="${getattr(item, valueattr)}">
15    ${getattr(item, descattr)}
16  </option>
17  #end for
18</select>
19#end def
20
21#def cdromList($default="", $onchange=None)
22#filter None
23$databaseList(sorted($sipb_xen_database.CDROM.select(), key=lambda x: x.description),
24              default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description')
25#end filter
26#end def
27
28#def autoList($default="", $onchange=None)
29#filter None
30$databaseList(sorted($sipb_xen_database.Autoinstall.select(), key=lambda x: x.description),
31              default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')
32#end filter
33#end def
34
35#def vmTypeList($default=None)
36#for $vmtype in (('linux-hvm', 'HVM'), ('linux', 'ParaVM'), )
37<label>
38   <input #slurp
39#if $default == $vmtype[0] then 'checked' else ''
40 type="radio" name="vmtype" value="${vmtype[0]}">${vmtype[1]}</input>
41</label>
42#end for
43#end def
44
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
60#filter None
61$full_body
62#end filter
63#end filter
Note: See TracBrowser for help on using the repository browser.