diff options
author | tiagonbotelho <tiagonbotelho@hotmail.com> | 2016-07-06 10:15:41 +0100 |
---|---|---|
committer | tiagonbotelho <tiagonbotelho@hotmail.com> | 2016-07-12 16:38:00 +0100 |
commit | ded67d3b68b438a71bb3771865981c3c7d0b3730 (patch) | |
tree | 153c7020c143bc1e458922430140a12349bd3b32 /lib | |
parent | be3409ab7ad3a8bf7b0c9eecb588598869459741 (diff) | |
download | gitlab-ce-ded67d3b68b438a71bb3771865981c3c7d0b3730.tar.gz |
implements filter_params
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/api/helpers.rb | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b62afb4bb4c..8673350b927 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -353,7 +353,9 @@ module API class ProjectWithAccess < Project expose :permissions do expose :project_access, using: Entities::ProjectAccess do |project, options| + project = Project.find_by(project[:id]) project.project_members.find_by(user_id: options[:user].id) + ] end expose :group_access, using: Entities::GroupAccess do |project, options| diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 77e407b54c5..3a1837effd8 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -287,6 +287,23 @@ module API # Projects helpers + def filter_params(projects) + project_entries = [] + + # Removes the redundant information of the object + projects.each do |project| + entry = { + id: project.id, + http_url_to_repo: project.http_url_to_repo, + name_with_namespace: project.name_with_namespace + } + + project_entries << entry + end + + project_entries + end + def filter_projects(projects) # If the archived parameter is passed, limit results accordingly if params[:archived].present? |