def search_user_from_ccnet(q): """ Return 10 items at most. """ users = [] db_users = ccnet_api.search_emailusers('DB', q, 0, 10) users.extend(db_users) count = len(users) if count < 10: ldap_imported_users = ccnet_api.search_emailusers('LDAP', q, 0, 10 - count) users.extend(ldap_imported_users) count = len(users) if count < 10 and ENABLE_SEARCH_FROM_LDAP_DIRECTLY: all_ldap_users = ccnet_api.search_ldapusers(q, 0, 10 - count) users.extend(all_ldap_users) # `users` is already search result, no need search more email_list = [] for user in users: email_list.append(user.email) return email_list
def search_user_from_ccnet(q): """ Return 10 items at most. """ users = [] db_users = ccnet_api.search_emailusers('DB', q, 0, 10) users.extend(db_users) count = len(users) if count < 10: ldap_imported_users = ccnet_api.search_emailusers('LDAP', q, 0, 10 - count) users.extend(ldap_imported_users) count = len(users) if count < 10 and ENABLE_SEARCH_FROM_LDAP_DIRECTLY: all_ldap_users = ccnet_api.search_ldapusers(q, 0, 10 - count) users.extend(all_ldap_users) # `users` is already search result, no need search more email_list = [] for user in users: email_list.append(user.email) return email_list