diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-13 13:32:35 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-13 13:32:35 +0000 |
commit | 9664424cab50ea2ac11669dc73c26f029e229fb9 (patch) | |
tree | 45c7159ee1816de0aab0d89956e821884eeae933 /lib/api/projects.rb | |
parent | bbc28428a6c6f0f4ded40a14bbc81f29daf28d5a (diff) | |
parent | fc4108b38b5d0a7fc755c1977663f516b5dea0bd (diff) | |
download | gitlab-ce-9664424cab50ea2ac11669dc73c26f029e229fb9.tar.gz |
Merge branch 'ci/api-projects' into 'master'
Extend projects API with CI data
Reference #4264
See merge request !2303
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 8b1390e3289..71bb342f844 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -69,7 +69,8 @@ module API # Example Request: # GET /projects/:id get ":id" do - present user_project, with: Entities::ProjectWithAccess, user: current_user + present user_project, with: Entities::ProjectWithAccess, user: current_user, + user_can_admin_project: can?(current_user, :admin_project, user_project) end # Get events for a single project @@ -118,7 +119,8 @@ module API attrs = map_public_to_visibility_level(attrs) @project = ::Projects::CreateService.new(current_user, attrs).execute if @project.saved? - present @project, with: Entities::Project + present @project, with: Entities::Project, + user_can_admin_project: can?(current_user, :admin_project, @project) else if @project.errors[:limit_reached].present? error!(@project.errors[:limit_reached], 403) @@ -163,7 +165,8 @@ module API attrs = map_public_to_visibility_level(attrs) @project = ::Projects::CreateService.new(user, attrs).execute if @project.saved? - present @project, with: Entities::Project + present @project, with: Entities::Project, + user_can_admin_project: can?(current_user, :admin_project, @project) else render_validation_error!(@project) end @@ -182,8 +185,9 @@ module API if @forked_project.errors.any? conflict!(@forked_project.errors.messages) else - present @forked_project, with: Entities::Project - end + present @forked_project, with: Entities::Project, + user_can_admin_project: can?(current_user, :admin_project, @forked_project) + end end # Update an existing project @@ -229,7 +233,8 @@ module API if user_project.errors.any? render_validation_error!(user_project) else - present user_project, with: Entities::Project + present user_project, with: Entities::Project, + user_can_admin_project: can?(current_user, :admin_project, user_project) end end |