mango r268 - in branches/django: . mango
- From: ovitters svn gnome org
- To: svn-commits-list gnome org,gnome-sysadmin gnome org
- Subject: mango r268 - in branches/django: . mango
- Date: Fri, 27 Jun 2008 21:20:48 +0000 (UTC)
Author: ovitters
Date: Fri Jun 27 21:20:48 2008
New Revision: 268
URL: http://svn.gnome.org/viewvc/mango?rev=268&view=rev
Log:
* mango/models.py (LdapObject._build_filter): Add hackish way to
specify a __contains LDAP query.
* mango/views.py (list_users): Allow filtering on uid, cn, mail.
Modified:
branches/django/ (props changed)
branches/django/ChangeLog
branches/django/mango/models.py
branches/django/mango/views.py
Modified: branches/django/mango/models.py
==============================================================================
--- branches/django/mango/models.py (original)
+++ branches/django/mango/models.py Fri Jun 27 21:20:48 2008
@@ -200,7 +200,10 @@
if isinstance(child, tree.Node):
val = cls._build_filter(child)
else:
- val = ldap.filter.filter_format('(%s=%s)', (child[0], child[1]))
+ if child[0].endswith('__contains'):
+ val = ldap.filter.filter_format('(%s=*%s*)', (child[0].rsplit('__contains',1)[0], child[1]))
+ else:
+ val = ldap.filter.filter_format('(%s=%s)', (child[0], child[1]))
vals.append(val)
format = ''
Modified: branches/django/mango/views.py
==============================================================================
--- branches/django/mango/views.py (original)
+++ branches/django/mango/views.py Fri Jun 27 21:20:48 2008
@@ -123,8 +123,12 @@
def list_users(request):
doc, pagenode = get_xmldoc('List Users', request, 'listusers')
- queryset = models.Users.search(attrlist=('uid', 'cn', 'mail'))
-
+ filter = setup_filter(pagenode, request.GET, {
+ 'keyword': lambda keyword: Q(uid__contains=keyword) | Q(cn__contains=keyword) | Q(mail__contains=keyword)
+ })
+
+ queryset = models.Users.search(filter, attrlist=('uid', 'cn', 'mail'))
+
page = setup_xml_paginator(request, pagenode, queryset)
for obj in page.object_list:
usernode = ET.SubElement(pagenode, 'user')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]