Added user search.
This commit is contained in:
parent
eaad5f4cae
commit
e52a489dc4
1 changed files with 35 additions and 14 deletions
|
@ -337,26 +337,47 @@ curl http://localhost/api/v1/users/2.json -v -u #{login}:#{password} -H "Content
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# do query
|
query_params = {
|
||||||
user_all = User.search(
|
|
||||||
:query => params[:term],
|
:query => params[:term],
|
||||||
:limit => params[:limit],
|
:limit => params[:limit],
|
||||||
:current_user => current_user,
|
: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
|
# build result list
|
||||||
|
if !params[:full]
|
||||||
users = []
|
users = []
|
||||||
user_all.each do |user|
|
user_all.each { |user|
|
||||||
realname = user.firstname.to_s + ' ' + user.lastname.to_s
|
realname = user.firstname.to_s + ' ' + user.lastname.to_s
|
||||||
if user.email && user.email.to_s != ''
|
if user.email && user.email.to_s != ''
|
||||||
realname = realname + ' <' + user.email.to_s + '>'
|
realname = realname + ' <' + user.email.to_s + '>'
|
||||||
end
|
end
|
||||||
a = { :id => user.id, :label => realname, :value => realname }
|
a = { :id => user.id, :label => realname, :value => realname }
|
||||||
users.push a
|
users.push a
|
||||||
end
|
}
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
render :json => users
|
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
|
end
|
||||||
|
|
||||||
# GET /api/v1/users/history/1
|
# GET /api/v1/users/history/1
|
||||||
|
|
Loading…
Reference in a new issue