Added user search.

This commit is contained in:
Martin Edenhofer 2014-09-25 01:12:23 +02:00
parent eaad5f4cae
commit e52a489dc4

View file

@ -337,26 +337,47 @@ curl http://localhost/api/v1/users/2.json -v -u #{login}:#{password} -H "Content
return
end
# do query
user_all = User.search(
query_params = {
:query => params[:term],
:limit => params[:limit],
:current_user => current_user,
)
}
if params[:role_ids] && !params[:role_ids].empty?
query_params[:role_ids] = params[:role_ids]
end
# do query
user_all = User.search(query_params)
# build result list
if !params[:full]
users = []
user_all.each do |user|
user_all.each { |user|
realname = user.firstname.to_s + ' ' + user.lastname.to_s
if user.email && user.email.to_s != ''
realname = realname + ' <' + user.email.to_s + '>'
end
a = { :id => user.id, :label => realname, :value => realname }
users.push a
end
}
# return result
render :json => users
return
end
user_ids = []
assets = {}
user_all.each { |user|
assets = user.assets(assets)
user_ids.push user.id
}
# return result
render :json => {
:assets => assets,
:user_ids => user_ids,
}
end
# GET /api/v1/users/history/1