summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-02-14 10:40:59 +0000
committerDouwe Maan <douwe@gitlab.com>2018-02-14 10:40:59 +0000
commit6085656bffa54cdbe21e776e283f87ece313991f (patch)
tree0798db9f44217da4ff340ab66844673e5e189839 /lib/api/projects.rb
parent5e829934f95bcae25f5c09583b6febe6e2e646b6 (diff)
parentb7cd99c376c2f953f30a4bf982b69780e3d6985b (diff)
downloadgitlab-ce-6085656bffa54cdbe21e776e283f87ece313991f.tar.gz
Merge branch 'feature/include-custom-attributes-in-api' into 'master'
Allow including custom attributes in API responses See merge request gitlab-org/gitlab-ce!16526
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 5b481121a10..e90892a90f7 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -3,6 +3,7 @@ require_dependency 'declarative_policy'
module API
class Projects < Grape::API
include PaginationParams
+ include Helpers::CustomAttributes
before { authenticate_non_get! }
@@ -80,6 +81,7 @@ module API
projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
projects = projects.with_statistics if params[:statistics]
projects = paginate(projects)
+ projects, options = with_custom_attributes(projects, options)
if current_user
project_members = current_user.project_members.preload(:source, user: [notification_settings: :source])
@@ -107,6 +109,7 @@ module API
requires :user_id, type: String, desc: 'The ID or username of the user'
use :collection_params
use :statistics_params
+ use :with_custom_attributes
end
get ":user_id/projects" do
user = find_user(params[:user_id])
@@ -127,6 +130,7 @@ module API
params do
use :collection_params
use :statistics_params
+ use :with_custom_attributes
end
get do
present_projects load_projects
@@ -196,11 +200,19 @@ module API
end
params do
use :statistics_params
+ use :with_custom_attributes
end
get ":id" do
- entity = current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails
- present user_project, with: entity, current_user: current_user,
- user_can_admin_project: can?(current_user, :admin_project, user_project), statistics: params[:statistics]
+ options = {
+ with: current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails,
+ current_user: current_user,
+ user_can_admin_project: can?(current_user, :admin_project, user_project),
+ statistics: params[:statistics]
+ }
+
+ project, options = with_custom_attributes(user_project, options)
+
+ present project, options
end
desc 'Fork new project for the current user or provided namespace.' do
@@ -242,6 +254,7 @@ module API
end
params do
use :collection_params
+ use :with_custom_attributes
end
get ':id/forks' do
forks = ForkProjectsFinder.new(user_project, params: project_finder_params, current_user: current_user).execute