Permalink
Browse files

In user search, don't return more than the required fields.

  • Loading branch information...
jcbrand committed May 9, 2014
1 parent 3dee2a9 commit 55543878cb065089af72fd3d3a444da0079289f7
Showing with 4 additions and 16 deletions.
  1. +4 −16 src/collective/xmpp/chat/browser/userinfo.py
@@ -20,19 +20,7 @@ def __call__(self):
if len(searchtext) < 2:
return []
panel = UsersOverviewControlPanel(self.context, self.request)
- users = panel.doSearch(searchtext)
- # complete name and surname can contain badly encoded values
- # when returned from plone.pas search therefore we try to convert
- # them to unicode with the latin characters encoding
- fields = ['cn', 'sn']
- for user_dict in users:
- for field in fields:
- try:
- field_value = user_dict.get(field)
- if field_value:
- user_dict[field] = unicode(field_value, "ISO-8859-1")
- except UnicodeDecodeError:
- users.remove(user_dict)
- log.warn("Can't decode %s", user_dict[field])
-
- return json.dumps(users)
+ return json.dumps([{
+ 'fullname': u['fullname'],
+ 'id': u['id']
+ } for u in panel.doSearch(searchtext)])

0 comments on commit 5554387

Please sign in to comment.