1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-05 09:08:53 +01:00
ldapcherry/resources/templates/form.tmpl

76 lines
2.9 KiB
Cheetah
Raw Normal View History

2015-06-27 22:35:34 +02:00
## -*- coding: utf-8 -*-
2015-06-10 22:45:04 +02:00
<%
2015-06-10 23:30:16 +02:00
len_attr = len(attributes)
switch = len_attr / 2
if not switch * 2 == len_attr:
switch = switch + 1
counter = 1
lc1 = []
lc2 = []
for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']):
if counter <= switch:
lc1.append(a)
else:
lc2.append(a)
counter = counter + 1
2015-06-10 22:45:04 +02:00
%>
2015-06-10 23:30:16 +02:00
<%def name="form_col(l)">
% for a in l:
2015-05-31 22:38:13 +02:00
<% attr = attributes[a] %>
<div class="form-group">
<div class="input-group">
<%
2015-06-18 23:43:58 +02:00
if modify:
required = ''
else:
required = ' required '
if not values is None and a in values:
2015-06-18 23:43:58 +02:00
if type(values[a]) is list:
tmp = values[a][0]
else:
tmp = values[a]
value = ' value="'+ tmp + '"'
value2 = '<option>'+ tmp +'</option>'
else:
value = ''
value2 = ''
%>
2015-06-18 23:43:58 +02:00
2015-05-31 22:38:13 +02:00
<span class="input-group-addon" id="basic-addon1">${attr['display_name']}</span>
% if modify and a == keyattr:
<input type="hidden" name="attr.${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" ${required} ${value}>
<span class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1">${tmp}</span>
% elif attr['type'] == 'string':
<input type="text" name="attr.${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" ${required} ${value}>
2015-05-31 22:38:13 +02:00
% elif attr['type'] == 'email':
<input type="email" name="attr.${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" ${required} ${value} data-error="email address is invalid">
2015-05-31 22:38:13 +02:00
% elif attr['type'] == 'int':
<input type="number" name="attr.${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" ${required} ${value}>
2015-05-31 22:38:13 +02:00
% elif attr['type'] == 'fix':
<input type="hidden" name="attr.${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" ${required} value="${attr['value']}">
<span class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1">${attr['value']}</span>
2015-05-31 22:38:13 +02:00
% elif attr['type'] == 'stringlist':
<select class="form-control" name="attr.${a}">
${value2}
2015-06-02 08:33:46 +02:00
%for val in attr['values']:
<option>${val}</option>
%endfor
</select>
2015-05-31 22:38:13 +02:00
% elif attr['type'] == 'password':
<input type="password" class="form-control" name="attr.${a}1" id="${a}1" placeholder="${attr['description']}" ${required}>
2015-06-03 23:57:22 +02:00
<span class="input-group-addon" id="basic-addon1">Retype ${attr['display_name']}</span>
<input type="password" class="form-control" name="attr.${a}2" id="#${a}2" data-match="#${a}1" placeholder="Confirm" ${required}>
2015-05-31 22:38:13 +02:00
% endif
</div>
</div>
2015-06-10 23:30:16 +02:00
% endfor
</%def>
<div class="row">
<div class="col-md-6 column">
${form_col(lc1)}
2015-06-10 22:45:04 +02:00
</div>
<div class="col-md-6 column">
2015-06-10 23:30:16 +02:00
${form_col(lc2)}
2015-06-10 22:45:04 +02:00
</div>
</div>