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

Last change on this file since 445 was 443, checked in by ecprice, 17 years ago

Support autoinstalls table for creation list.

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