Change userlist into a quick search form.

Add hack to update cn using givenname+sn (for now).
Change funcs.find_users() to not error if no results.
This commit is contained in:
Kevin McCarthy
2007-08-17 10:58:56 -07:00
parent 3184b5cd97
commit 8a0c3cb945
3 changed files with 49 additions and 20 deletions

View File

@@ -134,6 +134,11 @@ class Root(controllers.RootController):
set_ldap_value(new_user, 'sn', kw.get('sn'))
set_ldap_value(new_user, 'mail', kw.get('mail'))
set_ldap_value(new_user, 'telephonenumber', kw.get('telephonenumber'))
#
# this is a hack until we decide on the policy for names/cn/sn/givenName
#
set_ldap_value(new_user, 'sn',
"%s %s" % (kw.get('givenname'), kw.get('sn')))
orig_user = to_ldap_hash(orig_user)
new_user = to_ldap_hash(new_user)
@@ -148,11 +153,14 @@ class Root(controllers.RootController):
@expose("ipagui.templates.userlist")
@paginate('users', limit=3, allow_limit_override=True)
def userlist(self):
def userlist(self, **kw):
"""Retrieve a list of all users and display them in one huge list"""
users = client.get_all_users()
return dict(users=users)
users = None
uid = kw.get('uid')
if uid != None and len(uid) > 0:
users = client.find_users("*%s*" % uid)
return dict(users=users, fields=forms.user.UserFields())
@expose("ipagui.templates.usershow")

View File

@@ -6,21 +6,41 @@
<title>User Listing</title>
</head>
<body>
<fieldset>
<legend>People List</legend>
<div>
Page:
<span py:for="page in tg.paginate.pages">
<a py:if="page != tg.paginate.current_page"
href="${tg.paginate.get_href(page)}">${page}</a>
<b py:if="page == tg.paginate.current_page">${page}</b>
</span>
<p/>
<span py:for="user in users">
<a href="${tg.url('/usershow',uid=user.uid)}">${user.cn}</a>
<br/>
</span>
<div id="search">
<form action="${tg.url('/userlist')}" method="post">
Search by uid:
<input type="text" name="uid" />
<input type="submit" />
</form>
</div>
<div py:if='users != None'>
<h2>Results</h2>
<table py:if='len(users) > 0'>
<tr>
<th>
<label class="fieldlabel" py:content="fields.uid.label" />
</th>
<th>
Name
</th>
</tr>
<tr py:for="user in users">
<td>
<a href="${tg.url('/usershow',uid=user.uid)}">${user.uid}</a>
</td>
<td>
${user.cn}
</td>
</tr>
</table>
<div py:if='len(users) == 0'>
No results found.
</div>
</fieldset>
</div>
<!-- fix for visual artifact of my crappy ui -->
<div>
<br /><br /><br /><br />
</div>
</body>
</html>

View File

@@ -337,7 +337,8 @@ class IPAServer:
except ldap.LDAPError, e:
raise xmlrpclib.Fault(1, e)
except ipaserver.ipaldap.NoSuchEntryError:
raise xmlrpclib.Fault(2, "No such user")
results = []
# raise xmlrpclib.Fault(2, "No such user")
users = []
for u in results: