diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-11 09:27:24 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-11 09:27:24 +0000 |
commit | d10ecacc47c1bb640621eef620eb3099ca81f0da (patch) | |
tree | 3854cdcb2a13c43c70a3af96ea35ef4ae5ac07fd /lib/api/projects.rb | |
parent | 9d3e384ae6553fee85b7a1ed2b99a18a9884606e (diff) | |
parent | 37c4ba6f8d8b6be9f15bd0df701c64eea9c4d8e4 (diff) | |
download | gitlab-ce-d10ecacc47c1bb640621eef620eb3099ca81f0da.tar.gz |
Merge branch 'master' into 'master'
Let users limit by archived/not archived projects in GitLab API GET /projects
Adds a boolean parameter, archived, to the /projects endpoint.
See merge request !158
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 88c73bff32d..4c0766482f3 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -7,7 +7,7 @@ module API helpers do def map_public_to_visibility_level(attrs) publik = attrs.delete(:public) - publik = [ true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON' ].include?(publik) + publik = parse_boolean(publik) attrs[:visibility_level] = Gitlab::VisibilityLevel::PUBLIC if !attrs[:visibility_level].present? && publik == true attrs end @@ -15,10 +15,18 @@ module API # Get a projects list for authenticated user # + # Parameters: + # archived (optional) - if passed, limit by archived status + # # Example Request: # GET /projects get do - @projects = paginate current_user.authorized_projects + @query = current_user.authorized_projects + # If the archived parameter is passed, limit results accordingly + if params[:archived].present? + @query = @query.where(archived: parse_boolean(params[:archived])) + end + @projects = paginate @query present @projects, with: Entities::Project end |