1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-24 18:24:31 +01:00

adding textarea

This commit is contained in:
Stan Rudenko 2017-03-02 18:47:49 -08:00
parent e37b88dbda
commit f7f72c7e11
2 changed files with 13 additions and 8 deletions

View File

@ -16,7 +16,7 @@ from sets import Set
import yaml import yaml
# List of available types for form # List of available types for form
types = ['string', 'email', 'int', 'stringlist', 'fix', 'password'] types = ['string', 'textfield', 'email', 'int', 'stringlist', 'fix', 'password']
class Attributes: class Attributes:
@ -81,6 +81,8 @@ class Attributes:
attr_type = self.attributes[attrid]['type'] attr_type = self.attributes[attrid]['type']
if attr_type == 'string': if attr_type == 'string':
return return
elif attr_type == 'textfield':
return
elif attr_type == 'email': elif attr_type == 'email':
if self._is_email(value): if self._is_email(value):
return return

View File

@ -26,14 +26,15 @@ for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']):
required = ' required ' required = ' required '
if not values is None and a in values: if not values is None and a in values:
if type(values[a]) is list: if type(values[a]) is list:
tmp = values[a][0] raw_value = values[a][0]
else: else:
tmp = values[a] raw_value = values[a]
if tmp is None: if raw_value is None:
tmp = '' raw_value = ''
value = ' value="'+ tmp + '"' value = ' value="'+ raw_value + '"'
value2 = '<option>'+ tmp +'</option>' value2 = '<option>'+ raw_value +'</option>'
else: else:
raw_value = ''
value = '' value = ''
value2 = '' value2 = ''
if 'default' in attr and value == '': if 'default' in attr and value == '':
@ -43,7 +44,7 @@ for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']):
<span class="input-group-addon" id="basic-addon-${a}">${attr['display_name']}</span> <span class="input-group-addon" id="basic-addon-${a}">${attr['display_name']}</span>
% if modify and a == keyattr: % if modify and a == keyattr:
<input type="hidden" id="attr.${a}" name="attr.${a}" class="form-control" autocomplete='off' aria-describedby="basic-addon-${a}" ${required} ${value} readonly onfocus="this.removeAttribute('readonly');"> <input type="hidden" id="attr.${a}" name="attr.${a}" class="form-control" autocomplete='off' aria-describedby="basic-addon-${a}" ${required} ${value} readonly onfocus="this.removeAttribute('readonly');">
<span class="form-control" aria-describedby="basic-addon-${a}">${tmp}</span> <span class="form-control" aria-describedby="basic-addon-${a}">${raw_value}</span>
% elif attr['type'] == 'string': % elif attr['type'] == 'string':
<input type="text" id="attr.${a}" name="attr.${a}" class="form-control" autocomplete='off' placeholder="${attr['description']}" aria-describedby="basic-addon-${a}" ${required} ${value} readonly onfocus="this.removeAttribute('readonly');"> <input type="text" id="attr.${a}" name="attr.${a}" class="form-control" autocomplete='off' placeholder="${attr['description']}" aria-describedby="basic-addon-${a}" ${required} ${value} readonly onfocus="this.removeAttribute('readonly');">
% elif attr['type'] == 'email': % elif attr['type'] == 'email':
@ -64,6 +65,8 @@ for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']):
<input type="password" class="form-control" data-ppolicy="ppolicy" name="attr.${a}1" id="${a}1" autocomplete='off' placeholder="${attr['description']}" ${required} readonly onfocus="this.removeAttribute('readonly');"> <input type="password" class="form-control" data-ppolicy="ppolicy" name="attr.${a}1" id="${a}1" autocomplete='off' placeholder="${attr['description']}" ${required} readonly onfocus="this.removeAttribute('readonly');">
<span class="input-group-addon" id="basic-addon-${a}2">Retype ${attr['display_name']}</span> <span class="input-group-addon" id="basic-addon-${a}2">Retype ${attr['display_name']}</span>
<input type="password" class="form-control" data-match="#${a}1" data-match-error="Passwords don't match" name="attr.${a}2" id="#${a}2" autocomplete='off' placeholder="Confirm" ${required} readonly onfocus="this.removeAttribute('readonly');"> <input type="password" class="form-control" data-match="#${a}1" data-match-error="Passwords don't match" name="attr.${a}2" id="#${a}2" autocomplete='off' placeholder="Confirm" ${required} readonly onfocus="this.removeAttribute('readonly');">
% elif attr['type'] == 'textfield':
<textarea id="attr.${a}" name="attr.${a}" class="form-control" placeholder="${attr['description']}">${raw_value}</textarea>
% endif % endif
</div> </div>
<div class="help-block with-errors"></div> <div class="help-block with-errors"></div>