Add search box in header.

Change account status to use select list and 'active'/'inactive' values.
Improve autosuggest to keep suggesting unless you overwrite a suggestion
(if you correct the name, it will re-suggest).
This commit is contained in:
Kevin McCarthy
2007-09-06 11:09:12 -07:00
parent 268dd829df
commit 2adeed3029
7 changed files with 72 additions and 19 deletions
+8
View File
@@ -48,6 +48,14 @@ class Root(controllers.RootController):
def index(self):
return dict()
@expose()
def topsearch(self, **kw):
if kw.get('searchtype') == "Users":
return self.userlist(uid=kw.get('searchvalue'))
else:
return self.index()
########
# User #
+4 -1
View File
@@ -10,7 +10,10 @@ class UserFields():
sn = widgets.TextField(name="sn", label="Last name")
mail = widgets.TextField(name="mail", label="E-mail address")
telephonenumber = widgets.TextField(name="telephonenumber", label="Phone")
nsAccountLock = widgets.CheckBox(name="nsAccountLock", label="Account Deactivated")
# nsAccountLock = widgets.CheckBox(name="nsAccountLock", label="Account Deactivated")
nsAccountLock = widgets.SingleSelectField(name="nsAccountLock",
label="Account Status",
options = [("", "active"), ("true", "inactive")])
uid.validator = validators.PlainText(not_empty=True)
userpassword.validator = validators.String(not_empty=True)
@@ -21,3 +21,9 @@ def password_is_expired(days):
def password_expires_soon(days):
return (not password_is_expired(days)) and (days < 7)
def account_status_display(status):
if status == "true":
return "inactive"
else:
return "active"
+17 -8
View File
@@ -17,6 +17,7 @@ body {
background:#ccc; /* should be same as #sidebar */
margin:0 auto;
width:100%;
clear:both;
}
@@ -24,16 +25,25 @@ body {
background:#fff;
}
#header h1 {
padding:5px;
margin:0;
}
#header #logo {
float:left;
}
#header #login {
float:right;
#header #headerinfo {
text-align:right;
}
#header #headerinfo #login {
}
#header #headerinfo #topsearch {
padding-top: 15px;
}
.searchtext {
background-color:#E5F1F4;
border:1px solid #8E8E8E;
color:#444444;
}
@@ -42,7 +52,6 @@ body {
color:#fff;
min-height:3px;
max-height:3px;
clear:both;
}
#nav ul {
+29 -7
View File
@@ -24,19 +24,41 @@
</span>
</div>
<div id="page">
<div id="header">
<div id="header">
<div id="logo">
<a href="${tg.url('/')}"><img
src="${tg.url('/static/images/logo.png')}"
border="0"
/></a>
</div>
<div id="headerinfo">
<div id="login">
Logged in as: ace
</div>
<div id="logo">
<a href="${tg.url('/')}"><img
src="${tg.url('/static/images/logo.png')}"
border="0"
/></a>
<div id="topsearch">
<form action="${tg.url('/topsearch')}" method="post">
<select name="searchtype">
<option>Users</option>
<option>Groups</option>
</select>
<input class="searchtext" id="topsearchbox" type="text"
name="searchvalue"
value="Type search terms here."
onfocus="clearsearch()" />
<input type="submit" value="Search"/>
</form>
<script type="text/javascript">
function clearsearch() {
topsearchbox = document.getElementById('topsearchbox');
topsearchbox.onfocus = null;
topsearchbox.value = "";
}
</script>
</div>
</div>
</div>
<div id="page">
<div id="nav"><!--
This used to have links. Keeping around in case we move them back...
--></div>
@@ -27,6 +27,9 @@
<span py:if="tg.errors.get('sn')" class="fielderror"
py:content="tg.errors.get('sn')" />
<script type="text/javascript">
var uid_suggest = ""
var mail_suggest = ""
function autofill(self) {
givenname = document.getElementById('form_givenname');
sn = document.getElementById('form_sn');
@@ -35,22 +38,24 @@
}
uid = document.getElementById('form_uid');
mail = document.getElementById('form_mail');
if (uid.value == "") {
if ((uid.value == "") || (uid.value == uid_suggest)) {
new Ajax.Request('${tg.url('/suggest_uid')}', {
method: 'get',
parameters: {'givenname': givenname.value, 'sn': sn.value},
onSuccess: function(transport) {
uid.value = transport.responseText;
uid_suggest = uid.value;
new Effect.Highlight(uid);
}
});
}
if (mail.value == "") {
if ((mail.value == "") || (mail.value == mail_suggest)) {
new Ajax.Request('${tg.url('/suggest_email')}', {
method: 'get',
parameters: {'givenname': givenname.value, 'sn': sn.value},
onSuccess: function(transport) {
mail.value = transport.responseText;
mail_suggest = mail.value;
new Effect.Highlight(mail);
}
});
@@ -86,7 +86,7 @@ else:
<th>
<label class="fieldlabel" py:content="fields.nsAccountLock.label" />:
</th>
<td>${user.get("nsAccountLock")}</td>
<td>${userhelper.account_status_display(user.get("nsAccountLock"))}</td>
</tr>
</table>