mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
implementing adding default values to form
This commit is contained in:
parent
68c481c390
commit
e2497671cb
@ -445,7 +445,7 @@ class LdapCherry(object):
|
|||||||
def adduser(self, **params):
|
def adduser(self, **params):
|
||||||
""" add user page """
|
""" add user page """
|
||||||
self._check_auth(must_admin=True)
|
self._check_auth(must_admin=True)
|
||||||
form = self.temp_form.render(attributes=self.attributes.attributes)
|
form = self.temp_form.render(attributes=self.attributes.attributes, values=None)
|
||||||
return self.temp_adduser.render(form=form)
|
return self.temp_adduser.render(form=form)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@ -464,5 +464,5 @@ class LdapCherry(object):
|
|||||||
def selfmodify(self, **params):
|
def selfmodify(self, **params):
|
||||||
""" self modify user page """
|
""" self modify user page """
|
||||||
self._check_auth(must_admin=False)
|
self._check_auth(must_admin=False)
|
||||||
form = self.temp_form.render(attributes=self.attributes.get_selfattributes())
|
form = self.temp_form.render(attributes=self.attributes.get_selfattributes(), values=None)
|
||||||
return self.temp_selfmodify.render(form=form)
|
return self.temp_selfmodify.render(form=form)
|
||||||
|
@ -2,18 +2,27 @@
|
|||||||
<% attr = attributes[a] %>
|
<% attr = attributes[a] %>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
<%
|
||||||
|
if not values is None and a in values:
|
||||||
|
value = ' value="'+ values[a] + '"'
|
||||||
|
value2 = '<option>'+ values[a] +'</option>'
|
||||||
|
else:
|
||||||
|
value = ''
|
||||||
|
value2 = ''
|
||||||
|
%>
|
||||||
<span class="input-group-addon" id="basic-addon1">${attr['display_name']}</span>
|
<span class="input-group-addon" id="basic-addon1">${attr['display_name']}</span>
|
||||||
% if attr['type'] == 'string':
|
% if attr['type'] == 'string':
|
||||||
<input type="text" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required>
|
<input type="text" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required ${value}>
|
||||||
% elif attr['type'] == 'email':
|
% elif attr['type'] == 'email':
|
||||||
<input type="email" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required data-error="email address is invalid">
|
<input type="email" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required ${value} data-error="email address is invalid">
|
||||||
% elif attr['type'] == 'int':
|
% elif attr['type'] == 'int':
|
||||||
<input type="number" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required>
|
<input type="number" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required ${value}>
|
||||||
% elif attr['type'] == 'fix':
|
% elif attr['type'] == 'fix':
|
||||||
<input type="hidden" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required value="${attr['value']}">
|
<input type="hidden" name="${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>
|
<span class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1">${attr['value']}</span>
|
||||||
% elif attr['type'] == 'stringlist':
|
% elif attr['type'] == 'stringlist':
|
||||||
<select class="form-control" name="type">
|
<select class="form-control" name="type">
|
||||||
|
${value2}
|
||||||
%for val in attr['values']:
|
%for val in attr['values']:
|
||||||
<option>${val}</option>
|
<option>${val}</option>
|
||||||
%endfor
|
%endfor
|
||||||
|
Loading…
Reference in New Issue
Block a user