source: package_branches/invirt-web/cherrypy/code/templates/functions.mako @ 2398

Last change on this file since 2398 was 2393, checked in by quentin, 15 years ago

Port functions to Mako

File size: 1.3 KB
Line 
1<%def name="databaseList(lst, default, onchange, name, id, valueattr, descattr)">
2<select name="${name}" id="${id}"\
3% if onchange:
4onchange="${onchange}"\
5% endif
6>
7  <option ${'' if default else 'selected'} value="">None</option>
8  %for item in lst:
9  <option ${'selected' if default == getattr(item, valueattr) else ''} value="${getattr(item, valueattr)}">
10    ${getattr(item, descattr)}
11  </option>
12  % endfor
13</select>
14</%def>
15
16<%def name="cdromList(default='', onchange=None)">
17${databaseList(sorted(database.CDROM.query(), key=lambda x: x.description),
18               default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description')}
19</%def>
20
21<%def name="autoList(default='', onchange=None)">
22${databaseList(sorted(database.Autoinstall.query(), key=lambda x: x.description),
23               default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')}
24</%def>
25
26<%def name="vmTypeList(default=None)">
27% for vmtype in (('linux-hvm', 'HVM'), ('linux', 'ParaVM'), ):
28<label>
29   <input ${'checked="checked"' if default == vmtype[0] else ''} type="radio" name="vmtype" id="vmtype-${vmtype[0]}" value="${vmtype[0]}">${vmtype[1]}</input>
30</label>
31% endfor
32</%def>
33
34<%def name="errorRow(value, err)">
35% if err and err.err_field == value:
36<tr>
37<td class="error" colspan="2">${str(err)}</td>
38</tr>
39% endif
40</%def>
Note: See TracBrowser for help on using the repository browser.