added real names to admin user list combo

This commit is contained in:
smile 2013-11-12 21:28:00 +01:00
parent 2f7b13ac00
commit 8bf6c36bcb
2 changed files with 3 additions and 5 deletions

View file

@ -173,13 +173,11 @@ class MemberValues(object):
if (result_data == []): if (result_data == []):
break break
else: else:
## here you don't have to append to a list
## you could do whatever you want with the individual entry
## The appending to list is just for illustration.
if result_type == ldap.RES_SEARCH_ENTRY: if result_type == ldap.RES_SEARCH_ENTRY:
result_set.append(result_data) result_set.append(result_data)
userlist = [x[0][1]['uid'][0] for x in result_set] # list comprehension to get a list of user tupels in the format ("nickname", "nickname (real name)")
userlist = [(x[0][1]['uid'][0], '%s (%s)' % (x[0][1]['uid'][0], x[0][1]['cn'][0])) for x in result_set]
return sorted(userlist) return sorted(userlist)
except: except:
return [] return []

View file

@ -136,7 +136,7 @@ class AdminForm(forms.Form):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self._request = kwargs.pop('request', None) self._request = kwargs.pop('request', None)
self._users = kwargs.pop('users', []) self._users = kwargs.pop('users', [])
choices = [(x, x) for x in self._users] choices = [x for x in self._users]
choices.insert(0, ('', 'Select username ...')) choices.insert(0, ('', 'Select username ...'))
super(AdminForm, self).__init__(*args, **kwargs) super(AdminForm, self).__init__(*args, **kwargs)
self.fields.insert(0, 'username', forms.ChoiceField(choices=choices, self.fields.insert(0, 'username', forms.ChoiceField(choices=choices,