Commit 34d11a31 authored by tiagonbotelho's avatar tiagonbotelho

implements filter_params

parent 06c7d6f3
...@@ -331,7 +331,9 @@ module API ...@@ -331,7 +331,9 @@ module API
class ProjectWithAccess < Project class ProjectWithAccess < Project
expose :permissions do expose :permissions do
expose :project_access, using: Entities::ProjectAccess do |project, options| 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) project.project_members.find_by(user_id: options[:user].id)
]
end end
expose :group_access, using: Entities::GroupAccess do |project, options| expose :group_access, using: Entities::GroupAccess do |project, options|
......
...@@ -287,6 +287,23 @@ module API ...@@ -287,6 +287,23 @@ module API
# Projects helpers # 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) def filter_projects(projects)
# If the archived parameter is passed, limit results accordingly # If the archived parameter is passed, limit results accordingly
if params[:archived].present? if params[:archived].present?
......
...@@ -25,6 +25,8 @@ module API ...@@ -25,6 +25,8 @@ module API
@projects = current_user.authorized_projects @projects = current_user.authorized_projects
@projects = filter_projects(@projects) @projects = filter_projects(@projects)
@projects = paginate @projects @projects = paginate @projects
@projects = filter_params(@projects)
puts present @projects, with: Entities::ProjectWithAccess, user: current_user
present @projects, with: Entities::ProjectWithAccess, user: current_user present @projects, with: Entities::ProjectWithAccess, user: current_user
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment