Permalink
Browse files

refactor UserFilterAction code

Change-Id: Id068f01ee7a09caf84513b771e26cf43caca4113
  • Loading branch information...
1 parent 8734ea4 commit 18473fd2600794f74d2a134ad455c2e19500a6bc @mapleoin mapleoin committed Nov 27, 2012
Showing with 4 additions and 10 deletions.
  1. +4 −10 openstack_dashboard/dashboards/admin/users/tables.py
@@ -87,17 +87,11 @@ def delete(self, request, obj_id):
class UserFilterAction(tables.FilterAction):
def filter(self, table, users, filter_string):
- """ Really naive case-insensitive search. """
- # FIXME(gabriel): This should be smarter. Written for demo purposes.
+ """ Naive case-insensitive search """
q = filter_string.lower()
-
- def comp(user):
- if any([q in (user.name or "").lower(),
- q in (user.email or "").lower()]):
- return True
- return False
-
- return filter(comp, users)
+ return [user for user in users
+ if q in user.get('name', '').lower()
+ or q in user.get('email', '').lower()]
class UsersTable(tables.DataTable):

0 comments on commit 18473fd

Please sign in to comment.